Emote: format notification

This commit is contained in:
Benoit Marty 2023-10-05 15:31:10 +02:00
parent 3559b2ed4b
commit 5cb11e9cc9

View file

@ -87,7 +87,7 @@ class NotifiableEventResolver @Inject constructor(
noisy = isNoisy, noisy = isNoisy,
timestamp = this.timestamp, timestamp = this.timestamp,
senderName = senderDisplayName, senderName = senderDisplayName,
body = descriptionFromMessageContent(content), body = descriptionFromMessageContent(content, senderDisplayName ?: content.senderId.value),
imageUriString = this.contentUrl, imageUriString = this.contentUrl,
roomName = roomDisplayName, roomName = roomDisplayName,
roomIsDirect = isDirect, roomIsDirect = isDirect,
@ -133,7 +133,7 @@ class NotifiableEventResolver @Inject constructor(
NotificationContent.MessageLike.KeyVerificationStart -> null.also { NotificationContent.MessageLike.KeyVerificationStart -> null.also {
Timber.tag(loggerTag.value).d("Ignoring notification for verification ${content.javaClass.simpleName}") Timber.tag(loggerTag.value).d("Ignoring notification for verification ${content.javaClass.simpleName}")
} }
is NotificationContent.MessageLike.Poll -> { is NotificationContent.MessageLike.Poll -> {
buildNotifiableMessageEvent( buildNotifiableMessageEvent(
sessionId = userId, sessionId = userId,
senderId = content.senderId, senderId = content.senderId,
@ -205,10 +205,11 @@ class NotifiableEventResolver @Inject constructor(
private fun descriptionFromMessageContent( private fun descriptionFromMessageContent(
content: NotificationContent.MessageLike.RoomMessage, content: NotificationContent.MessageLike.RoomMessage,
senderDisplayName: String,
): String { ): String {
return when (val messageType = content.messageType) { return when (val messageType = content.messageType) {
is AudioMessageType -> messageType.body is AudioMessageType -> messageType.body
is EmoteMessageType -> messageType.body is EmoteMessageType -> "* $senderDisplayName ${messageType.body}"
is FileMessageType -> messageType.body is FileMessageType -> messageType.body
is ImageMessageType -> messageType.body is ImageMessageType -> messageType.body
is NoticeMessageType -> messageType.body is NoticeMessageType -> messageType.body