Start fixing notif for invites

This commit is contained in:
ganfra 2020-02-21 13:56:39 +01:00 committed by Benoit Marty
parent 981c9ac4ac
commit 9cdb1da614
3 changed files with 10 additions and 11 deletions

View File

@ -51,20 +51,20 @@ class NotifiableEventResolver @Inject constructor(private val stringProvider: St
fun resolveEvent(event: Event/*, roomState: RoomState?, bingRule: PushRule?*/, session: Session): NotifiableEvent? {
val roomID = event.roomId ?: return null
val eventId = event.eventId ?: return null
if (event.getClearType() == EventType.STATE_ROOM_MEMBER) {
return resolveStateRoomEvent(event, session)
}
val timelineEvent = session.getRoom(roomID)?.getTimeLineEvent(eventId) ?: return null
when (event.getClearType()) {
EventType.MESSAGE -> {
EventType.MESSAGE -> {
return resolveMessageEvent(timelineEvent, session)
}
EventType.ENCRYPTED -> {
EventType.ENCRYPTED -> {
val messageEvent = resolveMessageEvent(timelineEvent, session)
messageEvent?.lockScreenVisibility = NotificationCompat.VISIBILITY_PRIVATE
return messageEvent
}
EventType.STATE_ROOM_MEMBER -> {
return resolveStateRoomEvent(event, session)
}
else -> {
else -> {
// If the event can be displayed, display it as is
Timber.w("NotifiableEventResolver Received an unsupported event matching a bing rule")
// TODO Better event text display

View File

@ -130,9 +130,9 @@ class NotificationDrawerManager @Inject constructor(private val context: Context
fun onEventRedacted(eventId: String) {
synchronized(eventList) {
eventList.filter { it.eventId == eventId }.map { notifiableEvent ->
notifiableEvent.isRedacted = true
notifiableEvent.hasBeenDisplayed = false
eventList.find { it.eventId == eventId }?.apply {
isRedacted = true
hasBeenDisplayed = false
}
}
}
@ -182,7 +182,6 @@ class NotificationDrawerManager @Inject constructor(private val context: Context
e is InviteNotifiableEvent && e.roomId == roomId
}
}
notificationUtils.cancelNotificationMessage(roomId, ROOM_INVITATION_NOTIFICATION_ID)
}

View File

@ -515,7 +515,7 @@ class NotificationUtils @Inject constructor(private val context: Context,
val joinIntent = Intent(context, NotificationBroadcastReceiver::class.java)
joinIntent.action = JOIN_ACTION
joinIntent.data = Uri.parse("foobar://$roomId&$matrixId")
rejectIntent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomId)
joinIntent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomId)
val joinIntentPendingIntent = PendingIntent.getBroadcast(context, System.currentTimeMillis().toInt(), joinIntent,
PendingIntent.FLAG_UPDATE_CURRENT)
addAction(