mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-06-13 05:37:48 +02:00
fix(notifications): blacklist aliases
This commit is contained in:
@ -635,9 +635,8 @@
|
||||
"snap": "Snap",
|
||||
"typing": "Typing",
|
||||
"stories": "Stories",
|
||||
"chat_reaction": "Chat Reaction",
|
||||
"snap_reaction": "Snap Reaction",
|
||||
"voicenote_reaction": "Voice note Reaction",
|
||||
"chat_reaction": "DM Reaction",
|
||||
"group_chat_reaction": "Group Reaction",
|
||||
"initiate_audio": "Incoming Audio Call",
|
||||
"abandon_audio": "Missed Audio Call",
|
||||
"initiate_video": "Incoming Video Call",
|
||||
|
@ -10,6 +10,7 @@ enum class NotificationType (
|
||||
val key: String,
|
||||
val isIncoming: Boolean = false,
|
||||
val associatedOutgoingContentType: ContentType? = null,
|
||||
private vararg val aliases: String
|
||||
) {
|
||||
SCREENSHOT("chat_screenshot", true, ContentType.STATUS_CONVERSATION_CAPTURE_SCREENSHOT),
|
||||
SCREEN_RECORD("chat_screen_record", true, ContentType.STATUS_CONVERSATION_CAPTURE_RECORD),
|
||||
@ -20,15 +21,22 @@ enum class NotificationType (
|
||||
CHAT_REPLY("chat_reply",true),
|
||||
TYPING("typing", true),
|
||||
STORIES("stories",true),
|
||||
CHAT_REACTION("chat_reaction", true),
|
||||
SNAP_REACTION("snap_reaction", true),
|
||||
VOICENOTE_REACTION("voicenote_reaction", true),
|
||||
DM_REACTION("chat_reaction", true, null,"snap_reaction", "voicenote_reaction"),
|
||||
GROUP_REACTION("group_chat_reaction", true, null,"group_snap_reaction", "group_voicenote_reaction"),
|
||||
INITIATE_AUDIO("initiate_audio",true),
|
||||
ABANDON_AUDIO("abandon_audio", false, ContentType.STATUS_CALL_MISSED_AUDIO),
|
||||
INITIATE_VIDEO("initiate_video",true),
|
||||
ABANDON_VIDEO("abandon_video", false, ContentType.STATUS_CALL_MISSED_VIDEO);
|
||||
|
||||
fun isMatch(key: String): Boolean {
|
||||
return this.key == key || aliases.contains(key)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun getByKey(key: String): NotificationType? {
|
||||
return entries.firstOrNull { it.key == key }
|
||||
}
|
||||
|
||||
fun getIncomingValues(): List<NotificationType> {
|
||||
return entries.filter { it.isIncoming }.toList()
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import de.robv.android.xposed.XposedBridge
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import me.rhunk.snapenhance.common.data.ContentType
|
||||
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.util.protobuf.ProtoReader
|
||||
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")
|
||||
|
||||
if (states.contains(messageType.replaceFirst("mischief_", "")
|
||||
.replaceFirst("group_your_", "")
|
||||
.replaceFirst("group_other_", ""))
|
||||
) {
|
||||
val formattedMessageType = messageType.replaceFirst("mischief_", "")
|
||||
.replaceFirst("group_your_", "group_")
|
||||
.replaceFirst("group_other_", "group_")
|
||||
|
||||
if (states.mapNotNull { NotificationType.getByKey(it) }.any { it.isMatch(formattedMessageType) }) {
|
||||
param.setResult(null)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user