mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 11:59:12 +03:00
Merge pull request #5455 from vector-im/feature/ons/fix_poll_start_notifications
Show notification for poll start events but not for responses
This commit is contained in:
commit
db0cfd4704
5 changed files with 10 additions and 3 deletions
1
changelog.d/4780.bugfix
Normal file
1
changelog.d/4780.bugfix
Normal file
|
@ -0,0 +1 @@
|
|||
Poll system notifications on Android are not user friendly
|
|
@ -410,3 +410,5 @@ fun Event.isInvitation(): Boolean = type == EventType.STATE_ROOM_MEMBER &&
|
|||
fun Event.getPollContent(): MessagePollContent? {
|
||||
return content.toModel<MessagePollContent>()
|
||||
}
|
||||
|
||||
fun Event.supportsNotification() = this.getClearType() in EventType.MESSAGE + EventType.POLL_START
|
||||
|
|
|
@ -97,6 +97,7 @@ internal fun RealmQuery<TimelineEventEntity>.filterEvents(filters: TimelineEvent
|
|||
if (filters.filterEdits) {
|
||||
not().like(TimelineEventEntityFields.ROOT.CONTENT, TimelineEventFilter.Content.EDIT)
|
||||
not().like(TimelineEventEntityFields.ROOT.CONTENT, TimelineEventFilter.Content.RESPONSE)
|
||||
not().like(TimelineEventEntityFields.ROOT.CONTENT, TimelineEventFilter.Content.REFERENCE)
|
||||
}
|
||||
if (filters.filterRedacted) {
|
||||
not().like(TimelineEventEntityFields.ROOT.UNSIGNED_DATA, TimelineEventFilter.Unsigned.REDACTED)
|
||||
|
|
|
@ -26,6 +26,7 @@ internal object TimelineEventFilter {
|
|||
internal object Content {
|
||||
internal const val EDIT = """{*"m.relates_to"*"rel_type":*"m.replace"*}"""
|
||||
internal const val RESPONSE = """{*"m.relates_to"*"rel_type":*"org.matrix.response"*}"""
|
||||
internal const val REFERENCE = """{*"m.relates_to"*"rel_type":*"m.reference"*}"""
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.matrix.android.sdk.api.session.events.model.Event
|
|||
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||
import org.matrix.android.sdk.api.session.events.model.isEdition
|
||||
import org.matrix.android.sdk.api.session.events.model.isImageMessage
|
||||
import org.matrix.android.sdk.api.session.events.model.supportsNotification
|
||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomMemberContent
|
||||
|
@ -94,7 +95,7 @@ class NotifiableEventResolver @Inject constructor(
|
|||
}
|
||||
|
||||
suspend fun resolveInMemoryEvent(session: Session, event: Event, canBeReplaced: Boolean): NotifiableEvent? {
|
||||
if (event.getClearType() != EventType.MESSAGE) return null
|
||||
if (!event.supportsNotification()) return null
|
||||
|
||||
// Ignore message edition
|
||||
if (event.isEdition()) return null
|
||||
|
@ -153,7 +154,8 @@ class NotifiableEventResolver @Inject constructor(
|
|||
event.attemptToDecryptIfNeeded(session)
|
||||
// only convert encrypted messages to NotifiableMessageEvents
|
||||
when (event.root.getClearType()) {
|
||||
EventType.MESSAGE -> {
|
||||
EventType.MESSAGE,
|
||||
in EventType.POLL_START -> {
|
||||
val body = displayableEventFormatter.format(event, isDm = room.roomSummary()?.isDirect.orFalse(), appendAuthor = false).toString()
|
||||
val roomName = room.roomSummary()?.displayName ?: ""
|
||||
val senderDisplayName = event.senderInfo.disambiguatedDisplayName
|
||||
|
@ -185,7 +187,7 @@ class NotifiableEventResolver @Inject constructor(
|
|||
soundName = null
|
||||
)
|
||||
}
|
||||
else -> null
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue