feat: enhance notification handling with improved data structure and API integration

This commit is contained in:
2026-03-15 06:13:22 +07:00
parent 7675f66488
commit 0947c048c1
10 changed files with 349 additions and 169 deletions
+75 -26
View File
@@ -18,78 +18,127 @@ enum PreviewData {
static let mockNotifications: [AppNotification] = {
let now = Date()
let mockUserId = UUID(uuidString: "00000000-0000-0000-0000-000000000001")!
return [
AppNotification(
id: UUID(uuidString: "10000000-0000-0000-0000-000000000001")!,
topic: "Fire Alert",
userId: mockUserId,
scopeId: nil,
channel: .apns,
contentType: .plain,
templateId: nil,
subject: "Пожарная тревога",
body: "Обнаружено задымление на 12 этаже, корпус 9. Необходима немедленная эвакуация персонала.",
source: "Fire Alert",
metadata: ["Здание": "Корпус 9", "Этаж": "12", "Комната": "1A", "Датчик": "SM-4021"],
status: .delivered,
channel: .push,
status: .sent,
error: nil,
attempts: 1,
maxAttempts: 3,
nextRetryAt: nil,
sentAt: now.addingTimeInterval(-120),
readAt: nil,
createdAt: now.addingTimeInterval(-120),
updatedAt: now.addingTimeInterval(-120)
createdAt: now.addingTimeInterval(-120)
),
AppNotification(
id: UUID(uuidString: "10000000-0000-0000-0000-000000000002")!,
topic: "Security Alert",
userId: mockUserId,
scopeId: nil,
channel: .apns,
contentType: .plain,
templateId: nil,
subject: "Нарушение периметра",
body: "Зафиксировано несанкционированное проникновение через вход B2. Охрана уведомлена.",
source: "Security Alert",
metadata: ["Зона": "B2", "Камера": "CAM-17"],
status: .delivered,
channel: .push,
status: .sent,
error: nil,
attempts: 1,
maxAttempts: 3,
nextRetryAt: nil,
sentAt: now.addingTimeInterval(-300),
readAt: nil,
createdAt: now.addingTimeInterval(-300),
updatedAt: now.addingTimeInterval(-300)
createdAt: now.addingTimeInterval(-300)
),
AppNotification(
id: UUID(uuidString: "10000000-0000-0000-0000-000000000003")!,
topic: "Fire Alert",
userId: mockUserId,
scopeId: nil,
channel: .apns,
contentType: .plain,
templateId: nil,
subject: "Пожарная тревога",
body: "Сработала пожарная сигнализация в серверной. Автоматическая система пожаротушения активирована.",
source: "Fire Alert",
metadata: ["Здание": "Корпус 9", "Этаж": "12", "Комната": "1A"],
status: .read,
channel: .push,
error: nil,
attempts: 1,
maxAttempts: 3,
nextRetryAt: nil,
sentAt: now.addingTimeInterval(-7200),
readAt: now.addingTimeInterval(-3600),
createdAt: now.addingTimeInterval(-7200),
updatedAt: now.addingTimeInterval(-3600)
createdAt: now.addingTimeInterval(-7200)
),
AppNotification(
id: UUID(uuidString: "10000000-0000-0000-0000-000000000004")!,
topic: "Medical Emergency",
userId: mockUserId,
scopeId: nil,
channel: .apns,
contentType: .plain,
templateId: nil,
subject: "Медицинская помощь",
body: "Запрос экстренной медицинской помощи на 3 этаже, кабинет 312. Бригада скорой помощи вызвана.",
source: "Medical Emergency",
metadata: ["Здание": "Корпус 9", "Этаж": "3", "Комната": "312"],
status: .read,
channel: .push,
error: nil,
attempts: 1,
maxAttempts: 3,
nextRetryAt: nil,
sentAt: now.addingTimeInterval(-7200),
readAt: now.addingTimeInterval(-5400),
createdAt: now.addingTimeInterval(-7200),
updatedAt: now.addingTimeInterval(-5400)
createdAt: now.addingTimeInterval(-7200)
),
AppNotification(
id: UUID(uuidString: "10000000-0000-0000-0000-000000000005")!,
topic: "Water Leak",
userId: mockUserId,
scopeId: nil,
channel: .inApp,
contentType: .plain,
templateId: nil,
subject: "Затопление",
body: "Обнаружена утечка воды в подвальном помещении. Аварийная служба на месте.",
source: "Water Leak",
metadata: ["Здание": "Корпус 3", "Этаж": "B1"],
status: .read,
channel: .inApp,
error: nil,
attempts: 1,
maxAttempts: 3,
nextRetryAt: nil,
sentAt: now.addingTimeInterval(-90000),
readAt: now.addingTimeInterval(-86400),
createdAt: now.addingTimeInterval(-90000),
updatedAt: now.addingTimeInterval(-86400)
createdAt: now.addingTimeInterval(-90000)
),
AppNotification(
id: UUID(uuidString: "10000000-0000-0000-0000-000000000006")!,
topic: "Security Alert",
userId: mockUserId,
scopeId: nil,
channel: .inApp,
contentType: .plain,
templateId: nil,
subject: "Тестирование системы",
body: "Плановое тестирование системы оповещения. Действий не требуется.",
source: "Security Alert",
metadata: nil,
status: .read,
channel: .inApp,
error: nil,
attempts: 1,
maxAttempts: 3,
nextRetryAt: nil,
sentAt: now.addingTimeInterval(-180000),
readAt: now.addingTimeInterval(-172800),
createdAt: now.addingTimeInterval(-180000),
updatedAt: now.addingTimeInterval(-172800)
createdAt: now.addingTimeInterval(-180000)
),
]
}()