including the room name in the invitation event if the room sumary is available

This commit is contained in:
Adam Brown 2021-10-12 17:27:21 +01:00
parent 56e2b79774
commit beff5ab821
3 changed files with 5 additions and 2 deletions

View File

@ -21,6 +21,7 @@ data class InviteNotifiableEvent(
override val editedEventId: String?,
override val canBeReplaced: Boolean,
val roomId: String,
val roomName: String?,
val noisy: Boolean,
val title: String,
val description: String,

View File

@ -197,7 +197,8 @@ class NotifiableEventResolver @Inject constructor(
val roomId = event.roomId ?: return null
val dName = event.senderId?.let { session.getRoomMember(it, roomId)?.displayName }
if (Membership.INVITE == content.membership) {
val body = noticeEventFormatter.format(event, dName, isDm = session.getRoomSummary(roomId)?.isDirect.orFalse())
val roomSummary = session.getRoomSummary(roomId)
val body = noticeEventFormatter.format(event, dName, isDm = roomSummary?.isDirect.orFalse())
?: stringProvider.getString(R.string.notification_new_invitation)
return InviteNotifiableEvent(
session.myUserId,
@ -205,6 +206,7 @@ class NotifiableEventResolver @Inject constructor(
editedEventId = null,
canBeReplaced = canBeReplaced,
roomId = roomId,
roomName = roomSummary?.displayName,
timestamp = event.originServerTs ?: 0,
noisy = isNoisy,
title = stringProvider.getString(R.string.notification_new_invitation),

View File

@ -642,7 +642,7 @@ class NotificationUtils @Inject constructor(private val context: Context,
return NotificationCompat.Builder(context, channelID)
.setOnlyAlertOnce(true)
.setContentTitle(stringProvider.getString(R.string.app_name))
.setContentTitle(inviteNotifiableEvent.roomName ?: stringProvider.getString(R.string.app_name))
.setContentText(inviteNotifiableEvent.description)
.setGroup(stringProvider.getString(R.string.app_name))
.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_ALL)