mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-06-13 13:47:47 +02:00
feat: prevent snap replays
This commit is contained in:
@ -622,6 +622,7 @@
|
|||||||
"notifications": {
|
"notifications": {
|
||||||
"chat_screenshot": "Screenshot",
|
"chat_screenshot": "Screenshot",
|
||||||
"chat_screen_record": "Screen Record",
|
"chat_screen_record": "Screen Record",
|
||||||
|
"snap_replay": "Snap Replay",
|
||||||
"camera_roll_save": "Camera Roll Save",
|
"camera_roll_save": "Camera Roll Save",
|
||||||
"chat": "Chat",
|
"chat": "Chat",
|
||||||
"chat_reply": "Chat Reply",
|
"chat_reply": "Chat Reply",
|
||||||
|
@ -14,6 +14,7 @@ enum class NotificationType (
|
|||||||
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),
|
||||||
CAMERA_ROLL_SAVE("camera_roll_save", true, ContentType.STATUS_SAVE_TO_CAMERA_ROLL),
|
CAMERA_ROLL_SAVE("camera_roll_save", true, ContentType.STATUS_SAVE_TO_CAMERA_ROLL),
|
||||||
|
SNAP_REPLAY("snap_replay", true, ContentType.STATUS),
|
||||||
SNAP("snap",true),
|
SNAP("snap",true),
|
||||||
CHAT("chat",true),
|
CHAT("chat",true),
|
||||||
CHAT_REPLY("chat_reply",true),
|
CHAT_REPLY("chat_reply",true),
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package me.rhunk.snapenhance.features.impl.privacy
|
package me.rhunk.snapenhance.features.impl.privacy
|
||||||
|
|
||||||
import me.rhunk.snapenhance.core.event.events.impl.SendMessageWithContentEvent
|
import me.rhunk.snapenhance.core.event.events.impl.SendMessageWithContentEvent
|
||||||
|
import me.rhunk.snapenhance.core.event.events.impl.UnaryCallEvent
|
||||||
|
import me.rhunk.snapenhance.core.util.protobuf.ProtoEditor
|
||||||
import me.rhunk.snapenhance.data.NotificationType
|
import me.rhunk.snapenhance.data.NotificationType
|
||||||
import me.rhunk.snapenhance.features.Feature
|
import me.rhunk.snapenhance.features.Feature
|
||||||
import me.rhunk.snapenhance.features.FeatureLoadParams
|
import me.rhunk.snapenhance.features.FeatureLoadParams
|
||||||
@ -11,8 +13,19 @@ class PreventMessageSending : Feature("Prevent message sending", loadParams = Fe
|
|||||||
override fun asyncOnActivityCreate() {
|
override fun asyncOnActivityCreate() {
|
||||||
val preventMessageSending by context.config.messaging.preventMessageSending
|
val preventMessageSending by context.config.messaging.preventMessageSending
|
||||||
|
|
||||||
|
context.event.subscribe(UnaryCallEvent::class, { preventMessageSending.contains("snap_replay") }) { event ->
|
||||||
|
if (event.uri != "/messagingcoreservice.MessagingCoreService/UpdateContentMessage") return@subscribe
|
||||||
|
event.buffer = ProtoEditor(event.buffer).apply {
|
||||||
|
edit(3) {
|
||||||
|
// replace replayed to read receipt
|
||||||
|
remove(13)
|
||||||
|
addBuffer(4, byteArrayOf())
|
||||||
|
}
|
||||||
|
}.toByteArray()
|
||||||
|
}
|
||||||
|
|
||||||
context.classCache.conversationManager.hook("updateMessage", HookStage.BEFORE) { param ->
|
context.classCache.conversationManager.hook("updateMessage", HookStage.BEFORE) { param ->
|
||||||
val messageUpdate = param.arg<Any>(2).toString();
|
val messageUpdate = param.arg<Any>(2).toString()
|
||||||
if (messageUpdate == "SCREENSHOT" && preventMessageSending.contains("chat_screenshot")) {
|
if (messageUpdate == "SCREENSHOT" && preventMessageSending.contains("chat_screenshot")) {
|
||||||
param.setResult(null)
|
param.setResult(null)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user