diff --git a/library/ui-strings/src/main/res/values/strings.xml b/library/ui-strings/src/main/res/values/strings.xml index f7f1b8488f..12f6603260 100644 --- a/library/ui-strings/src/main/res/values/strings.xml +++ b/library/ui-strings/src/main/res/values/strings.xml @@ -2937,6 +2937,7 @@ Slide to end the call + Unsupported call Unsupported call. The new Element X app is needed to join this call. Re-Authentication Needed 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 196b419598..9a96b4b7e8 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 @@ -499,7 +499,11 @@ fun Event.getPollContent(): MessagePollContent? { } fun Event.supportsNotification() = - this.getClearType() in EventType.MESSAGE + EventType.POLL_START.values + EventType.POLL_END.values + EventType.STATE_ROOM_BEACON_INFO.values + this.getClearType() in EventType.MESSAGE + + EventType.POLL_START.values + + EventType.POLL_END.values + + EventType.STATE_ROOM_BEACON_INFO.values + + EventType.ELEMENT_CALL_NOTIFY.values fun Event.isContentReportable() = this.getClearType() in EventType.MESSAGE + EventType.STATE_ROOM_BEACON_INFO.values diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/ElementCallNotifyContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/ElementCallNotifyContent.kt index 50bef28fdc..4f8de7f8f7 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/ElementCallNotifyContent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/ElementCallNotifyContent.kt @@ -32,3 +32,8 @@ data class Mentions( @Json(name = "room") val room: Boolean? = null, @Json(name = "user_ids") val userIds: List? = null, ) + +fun ElementCallNotifyContent.isUserMentioned(userId: String): Boolean { + return mentions?.room == true || + mentions?.userIds?.contains(userId) == true +} diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushrules/ProcessEventForPushTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushrules/ProcessEventForPushTask.kt index d000d709a9..434512e2d3 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushrules/ProcessEventForPushTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushrules/ProcessEventForPushTask.kt @@ -61,6 +61,7 @@ internal class DefaultProcessEventForPushTask @Inject constructor( in EventType.POLL_START.values, in EventType.POLL_END.values, in EventType.STATE_ROOM_BEACON_INFO.values, + in EventType.ELEMENT_CALL_NOTIFY.values, EventType.MESSAGE, EventType.REDACTION, EventType.ENCRYPTED, diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt index 761f7d03ac..b9d2f1e779 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt @@ -214,6 +214,9 @@ class MessageActionsViewModel @AssistedInject constructor( in EventType.POLL_END.values -> { stringProvider.getString(CommonStrings.message_reply_to_ended_poll_preview) } + in EventType.ELEMENT_CALL_NOTIFY.values -> { + stringProvider.getString(CommonStrings.call_unsupported) + } else -> null } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/DisplayableEventFormatter.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/DisplayableEventFormatter.kt index d33c198f0d..8a6847f62d 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/DisplayableEventFormatter.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/DisplayableEventFormatter.kt @@ -142,6 +142,9 @@ class DisplayableEventFormatter @Inject constructor( in EventType.STATE_ROOM_BEACON_INFO.values -> { simpleFormat(senderName, stringProvider.getString(CommonStrings.sent_live_location), appendAuthor) } + in EventType.ELEMENT_CALL_NOTIFY.values -> { + simpleFormat(senderName, stringProvider.getString(CommonStrings.call_unsupported), appendAuthor) + } VoiceBroadcastConstants.STATE_ROOM_VOICE_BROADCAST_INFO -> { formatVoiceBroadcastEvent(timelineEvent.root, isDm, senderName) } @@ -243,6 +246,9 @@ class DisplayableEventFormatter @Inject constructor( in EventType.STATE_ROOM_BEACON_INFO.values -> { stringProvider.getString(CommonStrings.sent_live_location) } + in EventType.ELEMENT_CALL_NOTIFY.values -> { + stringProvider.getString(CommonStrings.call_unsupported) + } else -> { span { } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/TimelineDisplayableEvents.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/TimelineDisplayableEvents.kt index 67f03571c9..8e3a50d882 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/TimelineDisplayableEvents.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/TimelineDisplayableEvents.kt @@ -47,6 +47,7 @@ object TimelineDisplayableEvents { ) + EventType.POLL_START.values + EventType.POLL_END.values + + EventType.ELEMENT_CALL_NOTIFY.values + EventType.STATE_ROOM_BEACON_INFO.values + EventType.BEACON_LOCATION_DATA.values } diff --git a/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventResolver.kt b/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventResolver.kt index 271f6bca77..9979b71a44 100644 --- a/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventResolver.kt +++ b/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventResolver.kt @@ -34,7 +34,9 @@ import org.matrix.android.sdk.api.session.getUserOrDefault import org.matrix.android.sdk.api.session.room.getTimelineEvent import org.matrix.android.sdk.api.session.room.model.Membership import org.matrix.android.sdk.api.session.room.model.RoomMemberContent +import org.matrix.android.sdk.api.session.room.model.message.ElementCallNotifyContent import org.matrix.android.sdk.api.session.room.model.message.MessageWithAttachmentContent +import org.matrix.android.sdk.api.session.room.model.message.isUserMentioned import org.matrix.android.sdk.api.session.room.sender.SenderInfo import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent import org.matrix.android.sdk.api.session.room.timeline.getEditedEventId @@ -149,9 +151,11 @@ class NotifiableEventResolver @Inject constructor( ) } else { event.attemptToDecryptIfNeeded(session) - // only convert encrypted messages to NotifiableMessageEvents + // For incoming Element Call, check that the user is mentioned + val isIncomingElementCall = event.root.getClearType() in EventType.ELEMENT_CALL_NOTIFY.values && + event.root.getClearContent()?.toModel()?.isUserMentioned(session.myUserId) == true when { - event.root.supportsNotification() -> { + isIncomingElementCall || event.root.supportsNotification() -> { val body = displayableEventFormatter.format(event, isDm = room.roomSummary()?.isDirect.orFalse(), appendAuthor = false).toString() val roomName = room.roomSummary()?.displayName ?: "" val senderDisplayName = event.senderInfo.disambiguatedDisplayName