commit 28433922c5ed00740328ae7afcc4c763de6a79dd
parent fc65dfc626ea12091d502b0e48a8383929830c2b
Author: rhunk <101876869+rhunk@users.noreply.github.com>
Date:   Fri, 17 May 2024 16:37:29 +0200

fix: friend relationship changer mapper

Diffstat:
Mcore/src/main/kotlin/me/rhunk/snapenhance/core/action/impl/BulkMessagingAction.kt | 27++++++++++++++++++++-------
Mmapper/src/main/kotlin/me/rhunk/snapenhance/mapper/impl/FriendRelationshipChangerMapper.kt | 27+++++++++++++--------------
2 files changed, 33 insertions(+), 21 deletions(-)

diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/action/impl/BulkMessagingAction.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/action/impl/BulkMessagingAction.kt @@ -48,6 +48,7 @@ import me.rhunk.snapenhance.core.features.impl.experiments.AddFriendSourceSpoof import me.rhunk.snapenhance.core.features.impl.messaging.Messaging import me.rhunk.snapenhance.core.ui.ViewAppearanceHelper import me.rhunk.snapenhance.core.util.EvictingMap +import me.rhunk.snapenhance.core.util.dataBuilder import me.rhunk.snapenhance.mapper.impl.FriendRelationshipChangerMapper import java.net.URL import java.text.DateFormat @@ -537,16 +538,28 @@ class BulkMessagingAction : AbstractAction() { private fun removeFriend(userId: String) { context.mappings.useMapper(FriendRelationshipChangerMapper::class) { val friendRelationshipChangerInstance = context.feature(AddFriendSourceSpoof::class).friendRelationshipChangerInstance!! - val removeMethod = friendshipRelationshipChangerKtx.getAsClass()?.methods?.first { - it.name == removeFriendMethod.getAsString() - } ?: throw Exception("Failed to find removeFriend method") + val runFriendDurableJobMethod = classReference.getAsClass()?.methods?.first { + it.name == runFriendDurableJob.getAsString() + } ?: throw Exception("Failed to find runFriendDurableJobMethod method") + + val removeFriendDurableJob = context.androidContext.classLoader.loadClass("com.snap.identity.job.snapchatter.RemoveFriendDurableJob") + .constructors.firstOrNull { + it.parameterTypes.size == 1 + }?.run { + newInstance( + parameterTypes[0].dataBuilder { + set("a", userId) // userId + set("b", "DELETED_BY_MY_FRIENDS") // deleteSourceType + } + ) + } ?: throw Exception("Failed to create RemoveFriendDurableJob instance") - val completable = removeMethod.invoke(null, + val completable = runFriendDurableJobMethod.invoke(null, friendRelationshipChangerInstance, userId, // userId - removeMethod.parameterTypes[2].enumConstants.first { it.toString() == "DELETED_BY_MY_FRIENDS" }, // source - null, // InteractionPlacementInfo - 0 + removeFriendDurableJob, // friend durable job + 0x5, // action type + "DELETED_BY_MY_FRIENDS", // deleteSourceType )!! completable::class.java.methods.first { it.name == "subscribe" && it.parameterTypes.isEmpty() diff --git a/mapper/src/main/kotlin/me/rhunk/snapenhance/mapper/impl/FriendRelationshipChangerMapper.kt b/mapper/src/main/kotlin/me/rhunk/snapenhance/mapper/impl/FriendRelationshipChangerMapper.kt @@ -12,30 +12,28 @@ class FriendRelationshipChangerMapper : AbstractClassMapper("FriendRelationshipC val friendshipRelationshipChangerKtx = classReference("removeFriendClass") val addFriendMethod = string("addFriendMethod") - val removeFriendMethod = string("removeFriendMethod") + val runFriendDurableJob = string("runFriendDurableJob") init { mapper { for (classDef in classes) { classDef.methods.firstOrNull { it.name == "<init>" }?.implementation?.findConstString("FriendRelationshipChangerImpl")?.takeIf { it } ?: continue classReference.set(classDef.getClassName()) - return@mapper + + runFriendDurableJob.set(classDef.methods.firstOrNull { + Modifier.isStatic(it.accessFlags) && + it.returnType.contains("CompletableAndThenCompletable") && + it.parameterTypes.size == 5 && + it.parameterTypes[0] == classDef.type && + it.parameterTypes[1] == "Ljava/lang/String;" && + it.parameterTypes[3] == "I" && + it.parameterTypes[4] == "Ljava/lang/String;" + }?.name ?: continue) } } mapper { for (classDef in classes) { if (!classDef.isAbstract()) continue - val removeFriendDexMethod = classDef.methods.firstOrNull { - Modifier.isStatic(it.accessFlags) && - it.parameterTypes.size == 5 && - it.returnType.contains("io/reactivex/rxjava3") && - getClass(it.parameterTypes[2])?.isEnum() == true && - getClass(it.parameterTypes[3])?.getClassName()?.endsWith("InteractionPlacementInfo") == true - } ?: continue - - friendshipRelationshipChangerKtx.set(classDef.getClassName()) - removeFriendMethod.set(removeFriendDexMethod.name) - val addFriendDexMethod = classDef.methods.firstOrNull { Modifier.isStatic(it.accessFlags) && it.parameterTypes.size == 6 && @@ -43,8 +41,9 @@ class FriendRelationshipChangerMapper : AbstractClassMapper("FriendRelationshipC getClass(it.parameterTypes[2])?.isEnum() == true && getClass(it.parameterTypes[4])?.isEnum() == true && it.parameterTypes[5] == "I" - } ?: return@mapper + } ?: continue + friendshipRelationshipChangerKtx.set(classDef.getClassName()) addFriendMethod.set(addFriendDexMethod.name) return@mapper }