mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 13:38:49 +03:00
avoiding dispatching invitation accepted events
- we only want to notify users when they receive an invititation, not when they've accepted it
This commit is contained in:
parent
109a5a6664
commit
e95d49a3ae
1 changed files with 10 additions and 0 deletions
|
@ -17,7 +17,11 @@
|
|||
package org.matrix.android.sdk.internal.session.notification
|
||||
|
||||
import org.matrix.android.sdk.api.pushrules.rest.PushRule
|
||||
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.toModel
|
||||
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.sync.model.RoomsSyncResponse
|
||||
import org.matrix.android.sdk.internal.di.UserId
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
|
@ -51,11 +55,14 @@ internal class DefaultProcessEventForPushTask @Inject constructor(
|
|||
value.timeline?.events?.map { it.copy(roomId = key) }
|
||||
}
|
||||
.flatten()
|
||||
.filterNot { it.isInvitationJoined() }
|
||||
|
||||
val inviteEvents = params.syncResponse.invite
|
||||
.mapNotNull { (key, value) ->
|
||||
value.inviteState?.events?.map { it.copy(roomId = key) }
|
||||
}
|
||||
.flatten()
|
||||
|
||||
val allEvents = (newJoinEvents + inviteEvents).filter { event ->
|
||||
when (event.type) {
|
||||
EventType.MESSAGE,
|
||||
|
@ -93,3 +100,6 @@ internal class DefaultProcessEventForPushTask @Inject constructor(
|
|||
defaultPushRuleService.dispatchFinish()
|
||||
}
|
||||
}
|
||||
|
||||
private fun Event.isInvitationJoined(): Boolean = type == EventType.STATE_ROOM_MEMBER &&
|
||||
content?.toModel<RoomMemberContent>()?.membership == Membership.INVITE
|
||||
|
|
Loading…
Reference in a new issue