Skip to content

Commit aefeb01

Browse files
committed
Reduce the number of fallback notification. Only used now when message cannot be decrypted.
Also avoid using `else` in this `when` block.
1 parent cf657df commit aefeb01

File tree

1 file changed

+55
-2
lines changed

1 file changed

+55
-2
lines changed

libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/NotifiableEventResolver.kt

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,63 @@ class NotifiableEventResolver @Inject constructor(
114114
title = null, // TODO check if title is needed anymore
115115
)
116116
} else {
117-
fallbackNotifiableEvent(userId, roomId, eventId)
117+
Timber.tag(loggerTag.value).d("Ignoring notification state event for membership ${content.membershipState}")
118+
null
118119
}
119120
}
120-
else -> fallbackNotifiableEvent(userId, roomId, eventId)
121+
NotificationContent.MessageLike.CallAnswer,
122+
NotificationContent.MessageLike.CallCandidates,
123+
NotificationContent.MessageLike.CallHangup,
124+
NotificationContent.MessageLike.CallInvite -> null.also {
125+
Timber.tag(loggerTag.value).d("Ignoring notification for call ${content.javaClass.simpleName}")
126+
}
127+
NotificationContent.MessageLike.KeyVerificationAccept,
128+
NotificationContent.MessageLike.KeyVerificationCancel,
129+
NotificationContent.MessageLike.KeyVerificationDone,
130+
NotificationContent.MessageLike.KeyVerificationKey,
131+
NotificationContent.MessageLike.KeyVerificationMac,
132+
NotificationContent.MessageLike.KeyVerificationReady,
133+
NotificationContent.MessageLike.KeyVerificationStart -> null.also {
134+
Timber.tag(loggerTag.value).d("Ignoring notification for verification ${content.javaClass.simpleName}")
135+
}
136+
is NotificationContent.MessageLike.Poll -> null.also {
137+
// TODO Polls: handle notification rendering
138+
Timber.tag(loggerTag.value).d("Ignoring notification for poll")
139+
}
140+
is NotificationContent.MessageLike.ReactionContent -> null.also {
141+
Timber.tag(loggerTag.value).d("Ignoring notification for reaction")
142+
}
143+
NotificationContent.MessageLike.RoomEncrypted -> fallbackNotifiableEvent(userId, roomId, eventId).also {
144+
Timber.tag(loggerTag.value).w("Notification with encrypted content -> fallback")
145+
}
146+
NotificationContent.MessageLike.RoomRedaction -> null.also {
147+
Timber.tag(loggerTag.value).d("Ignoring notification for redaction")
148+
}
149+
NotificationContent.MessageLike.Sticker -> null.also {
150+
Timber.tag(loggerTag.value).d("Ignoring notification for sticker")
151+
}
152+
NotificationContent.StateEvent.PolicyRuleRoom,
153+
NotificationContent.StateEvent.PolicyRuleServer,
154+
NotificationContent.StateEvent.PolicyRuleUser,
155+
NotificationContent.StateEvent.RoomAliases,
156+
NotificationContent.StateEvent.RoomAvatar,
157+
NotificationContent.StateEvent.RoomCanonicalAlias,
158+
NotificationContent.StateEvent.RoomCreate,
159+
NotificationContent.StateEvent.RoomEncryption,
160+
NotificationContent.StateEvent.RoomGuestAccess,
161+
NotificationContent.StateEvent.RoomHistoryVisibility,
162+
NotificationContent.StateEvent.RoomJoinRules,
163+
NotificationContent.StateEvent.RoomName,
164+
NotificationContent.StateEvent.RoomPinnedEvents,
165+
NotificationContent.StateEvent.RoomPowerLevels,
166+
NotificationContent.StateEvent.RoomServerAcl,
167+
NotificationContent.StateEvent.RoomThirdPartyInvite,
168+
NotificationContent.StateEvent.RoomTombstone,
169+
NotificationContent.StateEvent.RoomTopic,
170+
NotificationContent.StateEvent.SpaceChild,
171+
NotificationContent.StateEvent.SpaceParent -> null.also {
172+
Timber.tag(loggerTag.value).d("Ignoring notification for state event ${content.javaClass.simpleName}")
173+
}
121174
}
122175
}
123176

0 commit comments

Comments
 (0)