mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-05-28 20:40:13 +02:00
fix: friend relationship changer mapper
This commit is contained in:
parent
fc65dfc626
commit
28433922c5
@ -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 completable = removeMethod.invoke(null,
|
||||
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 = 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()
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user