diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/Event.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/Event.kt index 57c083e757..df57ca5681 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/Event.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/Event.kt @@ -219,6 +219,13 @@ data class Event( return getDecryptedValue("formatted_body")?.contains("
") ?: false } + /** + * Determines whether or not current event has mentioned the user + */ + fun isUserMentioned(userId: String): Boolean { + return getDecryptedValue("formatted_body")?.contains(userId) ?: false + } + /** * Decrypt the message, or return the pure payload value if there is no encryption */ diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/helper/ThreadEventsHelper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/helper/ThreadEventsHelper.kt index 806b07316d..4f8643bc9e 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/helper/ThreadEventsHelper.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/helper/ThreadEventsHelper.kt @@ -210,8 +210,7 @@ internal fun findMyReadReceipt(realm: Realm, roomId: String, userId: String): St * Returns whether or not the user is mentioned in the event */ internal fun isUserMentioned(currentUserId: String, timelineEventEntity: TimelineEventEntity?): Boolean { - val decryptedContent = timelineEventEntity?.root?.asDomain()?.getDecryptedTextSummary().orEmpty() - return decryptedContent.contains(currentUserId.replace("@", "").substringBefore(":")) + return timelineEventEntity?.root?.asDomain()?.isUserMentioned(currentUserId) == true } /** diff --git a/vector/src/main/res/layout/view_thread_notification_badge.xml b/vector/src/main/res/layout/view_thread_notification_badge.xml index 8e2e098d7b..81b3f7138e 100644 --- a/vector/src/main/res/layout/view_thread_notification_badge.xml +++ b/vector/src/main/res/layout/view_thread_notification_badge.xml @@ -26,12 +26,11 @@