commit ead9e7830bd741e7b6321eac07ee4bc8eb76a94f
parent bf9444dfb62e8ca76e6ef06895e2d3ee92c41bed
Author: rhunk <101876869+rhunk@users.noreply.github.com>
Date:   Fri, 27 Oct 2023 02:47:17 +0200

feat: bypass message retention policy

Diffstat:
Mcommon/src/main/assets/lang/en_US.json | 10+++++++---
Mcommon/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/MessagingTweaks.kt | 3++-
Mcore/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/messaging/Messaging.kt | 10+++++++---
3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/common/src/main/assets/lang/en_US.json b/common/src/main/assets/lang/en_US.json @@ -328,6 +328,10 @@ "name": "Disable Replay in FF", "description": "Disables the ability to replay with a long press from the Friend Feed" }, + "message_preview_length": { + "name": "Message Preview Length", + "description": "Specify the amount of messages to get previewed" + }, "prevent_message_sending": { "name": "Prevent Message Sending", "description": "Prevents sending certain types of messages" @@ -352,9 +356,9 @@ "name": "Gallery Media Send Override", "description": "Spoofs the media source when sending from the Gallery" }, - "message_preview_length": { - "name": "Message Preview Length", - "description": "Specify the amount of messages to get previewed" + "bypass_message_retention_policy": { + "name": "Bypass Message Retention Policy", + "description": "Prevents messages from being deleted after viewing them" } } }, diff --git a/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/MessagingTweaks.kt b/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/MessagingTweaks.kt @@ -10,6 +10,7 @@ class MessagingTweaks : ConfigContainer() { val hideTypingNotifications = boolean("hide_typing_notifications") val unlimitedSnapViewTime = boolean("unlimited_snap_view_time") val disableReplayInFF = boolean("disable_replay_in_ff") + val messagePreviewLength = integer("message_preview_length", defaultValue = 20) val autoSaveMessagesInConversations = multiple("auto_save_messages_in_conversations", "CHAT", "SNAP", @@ -27,5 +28,5 @@ class MessagingTweaks : ConfigContainer() { } val messageLogger = boolean("message_logger") { addNotices(FeatureNotice.UNSTABLE); requireRestart() } val galleryMediaSendOverride = boolean("gallery_media_send_override") { nativeHooks() } - val messagePreviewLength = integer("message_preview_length", defaultValue = 20) + val bypassMessageRetentionPolicy = boolean("bypass_message_retention_policy") { addNotices(FeatureNotice.UNSTABLE); requireRestart() } } \ No newline at end of file diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/messaging/Messaging.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/messaging/Messaging.kt @@ -57,15 +57,19 @@ class Messaging : Feature("Messaging", loadParams = FeatureLoadParams.ACTIVITY_C } with(context.classCache.conversationManager) { - Hooker.hook(this, "enterConversation", HookStage.BEFORE) { - openedConversationUUID = SnapUUID(it.arg(0)) + Hooker.hook(this, "enterConversation", HookStage.BEFORE) { param -> + openedConversationUUID = SnapUUID(param.arg(0)) + if (context.config.messaging.bypassMessageRetentionPolicy.get()) { + val callback = param.argNullable<Any>(2) ?: return@hook + callback::class.java.methods.firstOrNull { it.name == "onSuccess" }?.invoke(callback) + param.setResult(null) + } } Hooker.hook(this, "exitConversation", HookStage.BEFORE) { openedConversationUUID = null } } - } override fun asyncInit() {