diff --git a/core/src/main/assets/lang/en_US.json b/core/src/main/assets/lang/en_US.json index 93d45eb3..68d62d26 100644 --- a/core/src/main/assets/lang/en_US.json +++ b/core/src/main/assets/lang/en_US.json @@ -304,6 +304,10 @@ "name": "Prevent Message Sending", "description": "Prevents sending certain types of messages" }, + "snap_to_chat_media": { + "name": "Snap to Chat Media", + "description": "Converts snaps to chat external media" + }, "better_notifications": { "name": "Better Notifications", "description": "Adds more information in received notifications" diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/config/impl/MessagingTweaks.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/config/impl/MessagingTweaks.kt index 3928fb84..7ea05d40 100644 --- a/core/src/main/kotlin/me/rhunk/snapenhance/core/config/impl/MessagingTweaks.kt +++ b/core/src/main/kotlin/me/rhunk/snapenhance/core/config/impl/MessagingTweaks.kt @@ -17,6 +17,7 @@ class MessagingTweaks : ConfigContainer() { "EXTERNAL_MEDIA", "STICKER" ) + val snapToChatMedia = boolean("snap_to_chat_media") val preventMessageSending = multiple("prevent_message_sending", *NotificationType.getOutgoingValues().map { it.key }.toTypedArray()) { customOptionTranslationPath = "features.options.notifications" } diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/features/impl/spying/SnapToChatMedia.kt b/core/src/main/kotlin/me/rhunk/snapenhance/features/impl/spying/SnapToChatMedia.kt new file mode 100644 index 00000000..b8892ec3 --- /dev/null +++ b/core/src/main/kotlin/me/rhunk/snapenhance/features/impl/spying/SnapToChatMedia.kt @@ -0,0 +1,28 @@ +package me.rhunk.snapenhance.features.impl.spying + +import me.rhunk.snapenhance.core.util.protobuf.ProtoReader +import me.rhunk.snapenhance.core.util.protobuf.ProtoWriter +import me.rhunk.snapenhance.data.ContentType +import me.rhunk.snapenhance.data.wrapper.impl.Message +import me.rhunk.snapenhance.features.Feature +import me.rhunk.snapenhance.features.FeatureLoadParams +import me.rhunk.snapenhance.hook.HookStage +import me.rhunk.snapenhance.hook.hookConstructor + +class SnapToChatMedia : Feature("SnapToChatMedia", loadParams = FeatureLoadParams.ACTIVITY_CREATE_SYNC) { + override fun onActivityCreate() { + if (!context.config.messaging.snapToChatMedia.get()) return + context.classCache.message.hookConstructor(HookStage.AFTER) { param -> + val message = Message(param.thisObject()) + + if (message.messageContent.contentType != ContentType.SNAP) return@hookConstructor + + val snapMessageContent = ProtoReader(message.messageContent.content).followPath(11)?.getBuffer() ?: return@hookConstructor + message.messageContent.content = ProtoWriter().apply { + from(3) { + addBuffer(3, snapMessageContent) + } + }.toByteArray() + } + } +} \ No newline at end of file diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/manager/impl/FeatureManager.kt b/core/src/main/kotlin/me/rhunk/snapenhance/manager/impl/FeatureManager.kt index c6c91b87..29bcf03c 100644 --- a/core/src/main/kotlin/me/rhunk/snapenhance/manager/impl/FeatureManager.kt +++ b/core/src/main/kotlin/me/rhunk/snapenhance/manager/impl/FeatureManager.kt @@ -15,6 +15,7 @@ import me.rhunk.snapenhance.features.impl.privacy.PreventMessageSending import me.rhunk.snapenhance.features.impl.spying.AnonymousStoryViewing import me.rhunk.snapenhance.features.impl.spying.MessageLogger import me.rhunk.snapenhance.features.impl.spying.PreventReadReceipts +import me.rhunk.snapenhance.features.impl.spying.SnapToChatMedia import me.rhunk.snapenhance.features.impl.spying.StealthMode import me.rhunk.snapenhance.features.impl.tweaks.* import me.rhunk.snapenhance.features.impl.ui.ClientBootstrapOverride @@ -84,6 +85,7 @@ class FeatureManager(private val context: ModContext) : Manager { AddFriendSourceSpoof::class, DisableReplayInFF::class, OldBitmojiSelfie::class, + SnapToChatMedia::class, ) initializeFeatures()