mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-21 08:55:42 +03:00
Render incoming Element Call in the notification (unsupported)
This commit is contained in:
parent
066545a4b3
commit
6e2a0cfa91
8 changed files with 28 additions and 3 deletions
|
@ -2937,6 +2937,7 @@
|
|||
|
||||
<string name="call_slide_to_end_conference">Slide to end the call</string>
|
||||
|
||||
<string name="call_unsupported">Unsupported call</string>
|
||||
<string name="call_unsupported_matrix_rtc_call">Unsupported call. The new Element X app is needed to join this call.</string>
|
||||
|
||||
<string name="re_authentication_activity_title">Re-Authentication Needed</string>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -32,3 +32,8 @@ data class Mentions(
|
|||
@Json(name = "room") val room: Boolean? = null,
|
||||
@Json(name = "user_ids") val userIds: List<String>? = null,
|
||||
)
|
||||
|
||||
fun ElementCallNotifyContent.isUserMentioned(userId: String): Boolean {
|
||||
return mentions?.room == true ||
|
||||
mentions?.userIds?.contains(userId) == true
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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<ElementCallNotifyContent>()?.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
|
||||
|
|
Loading…
Reference in a new issue