Include sender name in notification for invite content.

This commit is contained in:
Benoit Marty 2024-09-20 11:23:42 +02:00 committed by Benoit Marty
parent dfe9323455
commit ce650b06fb
3 changed files with 84 additions and 9 deletions

View file

@ -112,6 +112,7 @@ class DefaultNotifiableEventResolver @Inject constructor(
)
}
is NotificationContent.Invite -> {
val senderDisambiguatedDisplayName = getDisambiguatedDisplayName(content.senderId)
InviteNotifiableEvent(
sessionId = userId,
roomId = roomId,
@ -124,8 +125,7 @@ class DefaultNotifiableEventResolver @Inject constructor(
soundName = null,
isRedacted = false,
isUpdated = false,
// TODO We could use the senderId here
description = descriptionFromRoomMembershipInvite(isDirect),
description = descriptionFromRoomMembershipInvite(senderDisambiguatedDisplayName, isDirect),
// TODO check if type is needed anymore
type = null,
// TODO check if title is needed anymore
@ -278,12 +278,13 @@ class DefaultNotifiableEventResolver @Inject constructor(
}
private fun descriptionFromRoomMembershipInvite(
senderDisambiguatedDisplayName: String,
isDirectRoom: Boolean
): String {
return if (isDirectRoom) {
stringProvider.getString(R.string.notification_invite_body)
stringProvider.getString(R.string.notification_invite_body_with_sender, senderDisambiguatedDisplayName)
} else {
stringProvider.getString(R.string.notification_room_invite_body)
stringProvider.getString(R.string.notification_room_invite_body_with_sender, senderDisambiguatedDisplayName)
}
}

View file

@ -23,6 +23,7 @@
<item quantity="other">"%d invitations"</item>
</plurals>
<string name="notification_invite_body">"Invited you to chat"</string>
<string name="notification_invite_body_with_sender">"%1$s invited you to chat"</string>
<string name="notification_mentioned_you_body">"Mentioned you: %1$s"</string>
<string name="notification_new_messages">"New Messages"</string>
<plurals name="notification_new_messages_for_room">
@ -33,6 +34,7 @@
<string name="notification_room_action_mark_as_read">"Mark as read"</string>
<string name="notification_room_action_quick_reply">"Quick reply"</string>
<string name="notification_room_invite_body">"Invited you to join the room"</string>
<string name="notification_room_invite_body_with_sender">"%1$s invited you to join the room"</string>
<string name="notification_sender_me">"Me"</string>
<string name="notification_sender_mention_reply">"%1$s mentioned or replied"</string>
<string name="notification_test_push_notification_content">"You are viewing the notification! Click me!"</string>