Do not notify received reactions for messages we didn't sent + no longer repeat person reacting name in notification body

This commit is contained in:
Sylvain Berfini 2024-04-15 19:25:59 +02:00
parent c0b0ef66ff
commit 16fa960a0b
3 changed files with 8 additions and 8 deletions

View file

@ -206,15 +206,12 @@ class NotificationsManager @MainThread constructor(private val context: Context)
message: ChatMessage,
reaction: ChatMessageReaction
) {
val address = reaction.fromAddress
val defaultAccountAddress = core.defaultAccount?.params?.identityAddress
// Do not notify our own reactions, it won't be done anyway since the chat room is very likely to be currently displayed
if (defaultAccountAddress != null && defaultAccountAddress.weakEqual(address)) return
if (corePreferences.disableChat) return
val address = reaction.fromAddress
Log.i(
"$TAG Reaction received [${reaction.body}] from [${address.asStringUriOnly()}] for message [$message]"
)
if (corePreferences.disableChat) return
val id = LinphoneUtils.getChatRoomId(chatRoom)
/*if (id == currentlyDisplayedChatRoomId) {
@ -232,6 +229,10 @@ class NotificationsManager @MainThread constructor(private val context: Context)
Log.i("$TAG Reaction has been sent by ourselves, do not notify it")
return
}
if (!coreContext.isAddressMyself(message.fromAddress)) {
Log.i("$TAG Reaction isn't for a message we sent, do not notify it")
return
}
if (reaction.body.isNotEmpty()) {
showChatMessageReactionNotification(chatRoom, reaction.body, address, message)
@ -742,7 +743,6 @@ class NotificationsManager @MainThread constructor(private val context: Context)
val originalMessage = LinphoneUtils.getTextDescribingMessage(message)
val text = AppUtils.getString(R.string.notification_chat_message_reaction_received).format(
displayName,
reaction,
originalMessage
)

View file

@ -45,7 +45,7 @@
<string name="notification_channel_missed_call_name">&appName; notifications d\'appels manqués</string>
<string name="notification_channel_service_name">&appName; notification de service</string>
<string name="notification_channel_chat_name">&appName; notifications des conversations</string>
<string name="notification_chat_message_reaction_received">%s a réagi par %s à : %s</string>
<string name="notification_chat_message_reaction_received">A réagi par %s à : %s</string>
<string name="notification_mark_message_as_read">Marquer comme lu</string>
<string name="notification_reply_to_message">Répondre</string>
<string name="notification_missed_call">Appel manqué de %s</string>

View file

@ -80,7 +80,7 @@
<string name="notification_channel_missed_call_name">&appName; missed calls notifications</string>
<string name="notification_channel_service_name">&appName; service notification</string>
<string name="notification_channel_chat_name">&appName; instant messages notifications</string>
<string name="notification_chat_message_reaction_received">%s has reacted by %s to: %s</string>
<string name="notification_chat_message_reaction_received">Reacted by %s to: %s</string>
<string name="notification_mark_message_as_read">Mark as read</string>
<string name="notification_reply_to_message">Reply</string>
<string name="notification_missed_call">Missed call from %s</string>