mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-05-08 10:24:32 +02:00
feat(core/experimental): custom story expiration
- refactor send override
This commit is contained in:
parent
a01c2b09ca
commit
fe95a1bcc6
@ -460,10 +460,6 @@
|
|||||||
"disable_bitmoji": {
|
"disable_bitmoji": {
|
||||||
"name": "Disable Bitmoji",
|
"name": "Disable Bitmoji",
|
||||||
"description": "Disables Friends Profile Bitmoji"
|
"description": "Disables Friends Profile Bitmoji"
|
||||||
},
|
|
||||||
"fix_gallery_media_override": {
|
|
||||||
"name": "Fix Gallery Media Override",
|
|
||||||
"description": "Fixes various issues with the Gallery Media Send Override feature (e.g. Save Snaps in chat)"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -519,6 +515,10 @@
|
|||||||
"name": "Infinite Story Boost",
|
"name": "Infinite Story Boost",
|
||||||
"description": "Bypass the Story Boost Limit delay"
|
"description": "Bypass the Story Boost Limit delay"
|
||||||
},
|
},
|
||||||
|
"custom_story_expiration": {
|
||||||
|
"name": "Custom Story Expiration",
|
||||||
|
"description": "Set a custom story expiration time in hours (0 to disable)"
|
||||||
|
},
|
||||||
"meo_passcode_bypass": {
|
"meo_passcode_bypass": {
|
||||||
"name": "My Eyes Only Passcode Bypass",
|
"name": "My Eyes Only Passcode Bypass",
|
||||||
"description": "Bypass the My Eyes Only passcode\nThis will only work if the passcode has been entered correctly before"
|
"description": "Bypass the My Eyes Only passcode\nThis will only work if the passcode has been entered correctly before"
|
||||||
|
@ -6,7 +6,6 @@ import me.rhunk.snapenhance.common.config.FeatureNotice
|
|||||||
class Experimental : ConfigContainer() {
|
class Experimental : ConfigContainer() {
|
||||||
class NativeHooks : ConfigContainer(hasGlobalState = true) {
|
class NativeHooks : ConfigContainer(hasGlobalState = true) {
|
||||||
val disableBitmoji = boolean("disable_bitmoji")
|
val disableBitmoji = boolean("disable_bitmoji")
|
||||||
val fixGalleryMediaOverride = boolean("fix_gallery_media_override")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val nativeHooks = container("native_hooks", NativeHooks()) { icon = "Memory"; requireRestart() }
|
val nativeHooks = container("native_hooks", NativeHooks()) { icon = "Memory"; requireRestart() }
|
||||||
@ -15,6 +14,7 @@ class Experimental : ConfigContainer() {
|
|||||||
val appPasscode = string("app_passcode")
|
val appPasscode = string("app_passcode")
|
||||||
val appLockOnResume = boolean("app_lock_on_resume")
|
val appLockOnResume = boolean("app_lock_on_resume")
|
||||||
val infiniteStoryBoost = boolean("infinite_story_boost")
|
val infiniteStoryBoost = boolean("infinite_story_boost")
|
||||||
|
val customStoryExpiration = integer("custom_story_expiration") { requireRestart(); nativeHooks() }
|
||||||
val meoPasscodeBypass = boolean("meo_passcode_bypass")
|
val meoPasscodeBypass = boolean("meo_passcode_bypass")
|
||||||
val unlimitedMultiSnap = boolean("unlimited_multi_snap") { addNotices(FeatureNotice.BAN_RISK)}
|
val unlimitedMultiSnap = boolean("unlimited_multi_snap") { addNotices(FeatureNotice.BAN_RISK)}
|
||||||
val noFriendScoreDelay = boolean("no_friend_score_delay") { requireRestart()}
|
val noFriendScoreDelay = boolean("no_friend_score_delay") { requireRestart()}
|
||||||
|
@ -10,49 +10,57 @@ import me.rhunk.snapenhance.core.features.Feature
|
|||||||
import me.rhunk.snapenhance.core.features.FeatureLoadParams
|
import me.rhunk.snapenhance.core.features.FeatureLoadParams
|
||||||
import me.rhunk.snapenhance.core.messaging.MessageSender
|
import me.rhunk.snapenhance.core.messaging.MessageSender
|
||||||
import me.rhunk.snapenhance.core.ui.ViewAppearanceHelper
|
import me.rhunk.snapenhance.core.ui.ViewAppearanceHelper
|
||||||
|
import me.rhunk.snapenhance.nativelib.NativeLib
|
||||||
|
import kotlin.math.absoluteValue
|
||||||
|
|
||||||
class SendOverride : Feature("Send Override", loadParams = FeatureLoadParams.INIT_SYNC) {
|
class SendOverride : Feature("Send Override", loadParams = FeatureLoadParams.INIT_SYNC) {
|
||||||
private var isLastSnapSavable = false
|
private var isLastSnapSavable = false
|
||||||
|
private val typeNames by lazy {
|
||||||
override fun init() {
|
mutableListOf(
|
||||||
val fixGalleryMediaSendOverride = context.config.experimental.nativeHooks.let {
|
|
||||||
it.globalState == true && it.fixGalleryMediaOverride.get()
|
|
||||||
}
|
|
||||||
val typeNames = mutableListOf(
|
|
||||||
"ORIGINAL",
|
"ORIGINAL",
|
||||||
"SNAP",
|
"SNAP",
|
||||||
"NOTE"
|
"NOTE"
|
||||||
).also {
|
).also {
|
||||||
if (fixGalleryMediaSendOverride) {
|
if (NativeLib.initialized) {
|
||||||
it.add("SAVABLE_SNAP")
|
it.add("SAVABLE_SNAP")
|
||||||
}
|
}
|
||||||
}.associateWith {
|
}.associateWith {
|
||||||
it
|
it
|
||||||
}
|
}
|
||||||
|
|
||||||
context.event.subscribe(UnaryCallEvent::class, { fixGalleryMediaSendOverride }) { event ->
|
|
||||||
if (event.uri != "/messagingcoreservice.MessagingCoreService/CreateContentMessage") return@subscribe
|
|
||||||
if (!isLastSnapSavable) return@subscribe
|
|
||||||
ProtoReader(event.buffer).also {
|
|
||||||
// only affect snaps
|
|
||||||
if (!it.containsPath(*Constants.ARROYO_MEDIA_CONTAINER_PROTO_PATH, 11)) return@subscribe
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event.buffer = ProtoEditor(event.buffer).apply {
|
override fun init() {
|
||||||
//remove the max view time
|
context.event.subscribe(UnaryCallEvent::class) { event ->
|
||||||
edit(*Constants.ARROYO_MEDIA_CONTAINER_PROTO_PATH, 11, 5, 2) {
|
if (event.uri != "/messagingcoreservice.MessagingCoreService/CreateContentMessage") return@subscribe
|
||||||
|
val protoEditor = ProtoEditor(event.buffer)
|
||||||
|
|
||||||
|
context.config.experimental.customStoryExpiration.get().takeIf { it > 0 }?.absoluteValue?.also { expirationInHours ->
|
||||||
|
protoEditor.edit(3, 2, 2) {
|
||||||
|
remove(1)
|
||||||
|
add(1) {
|
||||||
|
from(2) {
|
||||||
|
addVarInt(1, expirationInHours)
|
||||||
|
context.log.verbose("add story expiration to $expirationInHours hours")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isLastSnapSavable && ProtoReader(event.buffer).containsPath(*Constants.ARROYO_MEDIA_CONTAINER_PROTO_PATH, 11)) {
|
||||||
|
protoEditor.edit(*Constants.ARROYO_MEDIA_CONTAINER_PROTO_PATH, 11, 5, 2) {
|
||||||
remove(8)
|
remove(8)
|
||||||
addBuffer(6, byteArrayOf())
|
addBuffer(6, byteArrayOf())
|
||||||
}
|
}
|
||||||
//make snaps savable in chat
|
//make snaps savable in chat
|
||||||
edit(4) {
|
protoEditor.edit(4) {
|
||||||
val savableState = firstOrNull(7)?.value ?: return@edit
|
val savableState = firstOrNull(7)?.value ?: return@edit
|
||||||
if (savableState == 2L) {
|
if (savableState == 2L) {
|
||||||
remove(7)
|
remove(7)
|
||||||
addVarInt(7, 3)
|
addVarInt(7, 3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.toByteArray()
|
}
|
||||||
|
event.buffer = protoEditor.toByteArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
context.event.subscribe(SendMessageWithContentEvent::class, {
|
context.event.subscribe(SendMessageWithContentEvent::class, {
|
||||||
|
@ -5,7 +5,8 @@ import android.util.Log
|
|||||||
class NativeLib {
|
class NativeLib {
|
||||||
var nativeUnaryCallCallback: (NativeRequestData) -> Unit = {}
|
var nativeUnaryCallCallback: (NativeRequestData) -> Unit = {}
|
||||||
companion object {
|
companion object {
|
||||||
private var initialized = false
|
var initialized = false
|
||||||
|
private set
|
||||||
}
|
}
|
||||||
|
|
||||||
fun initOnce(classloader: ClassLoader) {
|
fun initOnce(classloader: ClassLoader) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user