Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: generate notification conversation deleted - WPB-11658 #2381

Open
wants to merge 1 commit into
base: refactor/generate-notification-conversation-member-leave
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading