mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-06-12 21:27:47 +02:00
fix(core): snap save policy
This commit is contained in:
@ -13,7 +13,6 @@ import me.rhunk.snapenhance.nativelib.NativeLib
|
||||
|
||||
class SendOverride : Feature("Send Override", loadParams = FeatureLoadParams.INIT_SYNC) {
|
||||
private var isLastSnapSavable = false
|
||||
private val arroyoMessageContainerPath = intArrayOf(4, 4)
|
||||
private val typeNames by lazy {
|
||||
mutableListOf(
|
||||
"ORIGINAL",
|
||||
@ -31,20 +30,14 @@ class SendOverride : Feature("Send Override", loadParams = FeatureLoadParams.INI
|
||||
override fun init() {
|
||||
context.event.subscribe(NativeUnaryCallEvent::class) { event ->
|
||||
if (event.uri != "/messagingcoreservice.MessagingCoreService/CreateContentMessage") return@subscribe
|
||||
val protoEditor = ProtoEditor(event.buffer)
|
||||
|
||||
if (isLastSnapSavable && ProtoReader(event.buffer).containsPath(*arroyoMessageContainerPath, 11)) {
|
||||
protoEditor.edit(*arroyoMessageContainerPath, 11, 5, 2) {
|
||||
remove(8)
|
||||
addBuffer(6, byteArrayOf())
|
||||
}
|
||||
//make snaps savable in chat
|
||||
if (isLastSnapSavable) {
|
||||
val protoEditor = ProtoEditor(event.buffer)
|
||||
protoEditor.edit(4) {
|
||||
remove(7)
|
||||
addVarInt(7, 3)
|
||||
}
|
||||
event.buffer = protoEditor.toByteArray()
|
||||
}
|
||||
event.buffer = protoEditor.toByteArray()
|
||||
}
|
||||
|
||||
val stripSnapMetadata = context.config.messaging.stripMediaMetadata.get()
|
||||
|
@ -33,9 +33,10 @@ class UnsaveableMessages : MessagingRuleFeature(
|
||||
if (conversationIds.all { canUseRule(it) }) {
|
||||
event.buffer = ProtoEditor(event.buffer).apply {
|
||||
edit(4) {
|
||||
if ((firstOrNull(7)?.value ?: return@edit) == 2L && firstOrNull(2)?.value != ContentType.SNAP.id.toLong()) {
|
||||
val contentType = firstOrNull(2)?.value
|
||||
if (contentType != ContentType.STATUS.id.toLong()) {
|
||||
remove(7)
|
||||
addVarInt(7, 3)
|
||||
addVarInt(7, 1) // set savePolicy to PROHIBITED
|
||||
}
|
||||
}
|
||||
}.toByteArray()
|
||||
|
Reference in New Issue
Block a user