fix(notifications): blacklist aliases

This commit is contained in:
rhunk
2023-10-15 23:23:13 +02:00
parent 8f699e3902
commit de1b80c2a4
3 changed files with 19 additions and 10 deletions

View File

@ -635,9 +635,8 @@
"snap": "Snap", "snap": "Snap",
"typing": "Typing", "typing": "Typing",
"stories": "Stories", "stories": "Stories",
"chat_reaction": "Chat Reaction", "chat_reaction": "DM Reaction",
"snap_reaction": "Snap Reaction", "group_chat_reaction": "Group Reaction",
"voicenote_reaction": "Voice note Reaction",
"initiate_audio": "Incoming Audio Call", "initiate_audio": "Incoming Audio Call",
"abandon_audio": "Missed Audio Call", "abandon_audio": "Missed Audio Call",
"initiate_video": "Incoming Video Call", "initiate_video": "Incoming Video Call",

View File

@ -10,6 +10,7 @@ enum class NotificationType (
val key: String, val key: String,
val isIncoming: Boolean = false, val isIncoming: Boolean = false,
val associatedOutgoingContentType: ContentType? = null, val associatedOutgoingContentType: ContentType? = null,
private vararg val aliases: String
) { ) {
SCREENSHOT("chat_screenshot", true, ContentType.STATUS_CONVERSATION_CAPTURE_SCREENSHOT), SCREENSHOT("chat_screenshot", true, ContentType.STATUS_CONVERSATION_CAPTURE_SCREENSHOT),
SCREEN_RECORD("chat_screen_record", true, ContentType.STATUS_CONVERSATION_CAPTURE_RECORD), SCREEN_RECORD("chat_screen_record", true, ContentType.STATUS_CONVERSATION_CAPTURE_RECORD),
@ -20,15 +21,22 @@ enum class NotificationType (
CHAT_REPLY("chat_reply",true), CHAT_REPLY("chat_reply",true),
TYPING("typing", true), TYPING("typing", true),
STORIES("stories",true), STORIES("stories",true),
CHAT_REACTION("chat_reaction", true), DM_REACTION("chat_reaction", true, null,"snap_reaction", "voicenote_reaction"),
SNAP_REACTION("snap_reaction", true), GROUP_REACTION("group_chat_reaction", true, null,"group_snap_reaction", "group_voicenote_reaction"),
VOICENOTE_REACTION("voicenote_reaction", true),
INITIATE_AUDIO("initiate_audio",true), INITIATE_AUDIO("initiate_audio",true),
ABANDON_AUDIO("abandon_audio", false, ContentType.STATUS_CALL_MISSED_AUDIO), ABANDON_AUDIO("abandon_audio", false, ContentType.STATUS_CALL_MISSED_AUDIO),
INITIATE_VIDEO("initiate_video",true), INITIATE_VIDEO("initiate_video",true),
ABANDON_VIDEO("abandon_video", false, ContentType.STATUS_CALL_MISSED_VIDEO); ABANDON_VIDEO("abandon_video", false, ContentType.STATUS_CALL_MISSED_VIDEO);
fun isMatch(key: String): Boolean {
return this.key == key || aliases.contains(key)
}
companion object { companion object {
fun getByKey(key: String): NotificationType? {
return entries.firstOrNull { it.key == key }
}
fun getIncomingValues(): List<NotificationType> { fun getIncomingValues(): List<NotificationType> {
return entries.filter { it.isIncoming }.toList() return entries.filter { it.isIncoming }.toList()
} }

View File

@ -14,6 +14,7 @@ import de.robv.android.xposed.XposedBridge
import de.robv.android.xposed.XposedHelpers import de.robv.android.xposed.XposedHelpers
import me.rhunk.snapenhance.common.data.ContentType import me.rhunk.snapenhance.common.data.ContentType
import me.rhunk.snapenhance.common.data.MediaReferenceType import me.rhunk.snapenhance.common.data.MediaReferenceType
import me.rhunk.snapenhance.common.data.NotificationType
import me.rhunk.snapenhance.common.data.download.SplitMediaAssetType import me.rhunk.snapenhance.common.data.download.SplitMediaAssetType
import me.rhunk.snapenhance.common.util.protobuf.ProtoReader import me.rhunk.snapenhance.common.util.protobuf.ProtoReader
import me.rhunk.snapenhance.common.util.snap.MediaDownloaderHelper import me.rhunk.snapenhance.common.util.snap.MediaDownloaderHelper
@ -354,10 +355,11 @@ class Notifications : Feature("Notifications", loadParams = FeatureLoadParams.IN
context.log.debug("received message type: $messageType") context.log.debug("received message type: $messageType")
if (states.contains(messageType.replaceFirst("mischief_", "") val formattedMessageType = messageType.replaceFirst("mischief_", "")
.replaceFirst("group_your_", "") .replaceFirst("group_your_", "group_")
.replaceFirst("group_other_", "")) .replaceFirst("group_other_", "group_")
) {
if (states.mapNotNull { NotificationType.getByKey(it) }.any { it.isMatch(formattedMessageType) }) {
param.setResult(null) param.setResult(null)
} }
} }