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 created - WPB-11657 #2379

Open
wants to merge 2 commits 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 @@ -102,8 +102,7 @@ struct NewSystemMessageNotificationBuilder: NotificationBuilder {
case .memberLeave:
return buildMemberLeaveNotification()
case .conversationCreated:
// TODO: [WPB-11657]
break
return buildConversationCreatedNotification()
case .memberJoin:
// TODO: [WPB-11661]
break
Expand Down Expand Up @@ -140,6 +139,26 @@ struct NewSystemMessageNotificationBuilder: NotificationBuilder {
return content
}

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

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

let body = NotificationBody.newSystemMessage(
.createdConversation(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 @@ -25,8 +25,7 @@ struct NewSystemMessageNotificationBodyComposer {
func make() -> String {
switch format {
case let .createdConversation(senderName):
// TODO: [WPB-11657]
""
senderName != nil ? "\(senderName!) created a conversation" : "Someone created a conversation"
case let .removedYou(senderName):
senderName != nil ? "\(senderName!) removed you" : "Someone removed you"
case let .setMessageTimer(senderName):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,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
.conversationCreated
]

for systemMessage in systemMessages {
Expand Down Expand Up @@ -119,7 +120,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
.conversationCreated
]

for systemMessage in systemMessages {
Expand Down Expand Up @@ -154,7 +156,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
.conversationCreated
]

for systemMessage in systemMessages {
Expand Down Expand Up @@ -232,7 +235,7 @@ final class NewSystemMessageNotificationBuilderTests: XCTestCase {
case .memberLeave:
XCTAssertEqual(notificationContent.body, "\(Scaffolding.senderName) removed you")
case .conversationCreated:
break
XCTAssertEqual(notificationContent.body, "\(Scaffolding.senderName) created a conversation")
case .memberJoin:
break
case .conversationDeleted:
Expand Down
Loading