Skip to content

Commit

Permalink
generate notification for deleted conversation, add UT
Browse files Browse the repository at this point in the history
  • Loading branch information
jullianm committed Jan 13, 2025
1 parent 16d2b8e commit 8ac66ab
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ struct NewSystemMessageNotificationBuilder: NotificationBuilder {
// TODO: [WPB-11661]
break
case .conversationDeleted:
// TODO: [WPB-11658]
break
return buildDeletedConversationNotification()
case .messageTimerUpdate:
// TODO: [WPB-11663]
break
Expand Down Expand Up @@ -140,6 +139,26 @@ struct NewSystemMessageNotificationBuilder: NotificationBuilder {
return content
}

private func buildDeletedConversationNotification() -> UNMutableNotificationContent {
let content = UNMutableNotificationContent()

if let title = makeTitle() {
content.title = title
}

let body = NotificationBody.newSystemMessage(
.deletedGroup(senderName: context.senderName)
)

content.body = body.make()
content.categoryIdentifier = makeCategory()
content.sound = makeSound()
content.userInfo = makeUserInfo()
content.threadIdentifier = context.conversationID.uuid.transportString()

return content
}

// MARK: - Helpers

private func makeTitle() -> String? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ struct NewSystemMessageNotificationBodyComposer {
// TODO: [WPB-11663]
""
case let .deletedGroup(senderName):
// TODO: [WPB-11658]
""
senderName != nil ? "\(senderName!) deleted the group" : "Someone deleted the group"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ final class NewSystemMessageNotificationBuilderTests: XCTestCase {
await setupMock(isGroup: isGroup, isTeam: isTeam, selfUserID: .mockID4)

let systemMessages: [NewSystemMessageNotificationBuilder.SystemMessage] = [
.memberLeave(removedUserIDs: [.mockID4]) // concerns self user
.memberLeave(removedUserIDs: [.mockID4]), // concerns self user
.conversationDeleted
]

for systemMessage in systemMessages {
Expand Down Expand Up @@ -154,7 +155,8 @@ final class NewSystemMessageNotificationBuilderTests: XCTestCase {
await setupMock(isGroup: isGroup, isTeam: isTeam, selfUserID: .mockID4)

let systemMessages: [NewSystemMessageNotificationBuilder.SystemMessage] = [
.memberLeave(removedUserIDs: [.mockID4]) // concerns self user
.memberLeave(removedUserIDs: [.mockID4]), // concerns self user
.conversationDeleted
]

for systemMessage in systemMessages {
Expand Down Expand Up @@ -236,7 +238,7 @@ final class NewSystemMessageNotificationBuilderTests: XCTestCase {
case .memberJoin:
break
case .conversationDeleted:
break
XCTAssertEqual(notificationContent.body, "\(Scaffolding.senderName) deleted the group")
case .messageTimerUpdate:
break
}
Expand Down

0 comments on commit 8ac66ab

Please sign in to comment.