mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-05-29 04:50:15 +02:00
fix(mapper): remove friend
This commit is contained in:
parent
54d3010970
commit
f0aa035f7c
@ -148,21 +148,20 @@ class BulkMessagingAction : AbstractAction() {
|
||||
private fun removeFriend(userId: String) {
|
||||
context.mappings.useMapper(FriendRelationshipChangerMapper::class) {
|
||||
val friendRelationshipChangerInstance = context.feature(AddFriendSourceSpoof::class).friendRelationshipChangerInstance!!
|
||||
val removeFriendMethod = friendRelationshipChangerInstance::class.java.methods.first {
|
||||
it.name == this.removeFriendMethod.get()
|
||||
}
|
||||
val removeMethod = removeFriendClass.getAsClass()?.methods?.first {
|
||||
it.name == removeFriendMethod.getAsString()
|
||||
} ?: throw Exception("Failed to find removeFriend method")
|
||||
|
||||
val completable = removeFriendMethod.invoke(friendRelationshipChangerInstance,
|
||||
val completable = removeMethod.invoke(null,
|
||||
friendRelationshipChangerInstance,
|
||||
userId, // userId
|
||||
removeFriendMethod.parameterTypes[1].enumConstants.first { it.toString() == "DELETED_BY_MY_FRIENDS" }, // source
|
||||
null, // unknown
|
||||
null, // unknown
|
||||
null // InteractionPlacementInfo
|
||||
removeMethod.parameterTypes[2].enumConstants.first { it.toString() == "DELETED_BY_MY_FRIENDS" }, // source
|
||||
null, // InteractionPlacementInfo
|
||||
0
|
||||
)!!
|
||||
completable::class.java.methods.first {
|
||||
it.name == "subscribe" && it.parameterTypes.isEmpty()
|
||||
}.invoke(completable)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -20,7 +20,7 @@ bcprov-jdk18on = "1.77"
|
||||
dexlib2 = "3.0.3"
|
||||
ffmpeg-kit = "5.1.LTS" # DO NOT UPDATE FFMPEG-KIT TO "5.1" it breaks stuff :3
|
||||
gson = "2.10.1"
|
||||
junit = "5.10.1"
|
||||
junit = "4.13.2"
|
||||
material3 = "1.1.2"
|
||||
okhttp = "5.0.0-alpha.12"
|
||||
rhino = "1.7.14"
|
||||
@ -48,7 +48,7 @@ ffmpeg-kit = { group = "com.arthenica", name = "ffmpeg-kit-full-gpl", version.re
|
||||
gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }
|
||||
guava = { module = "com.google.guava:guava", version.ref = "guava" }
|
||||
jsoup = { module = "org.jsoup:jsoup", version.ref = "jsoup" }
|
||||
junit = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "junit" }
|
||||
junit = { module = "junit:junit", version.ref = "junit" }
|
||||
okhttp = { group = "com.squareup.okhttp3", name = "okhttp", version.ref = "okhttp" }
|
||||
osmdroid-android = { group = "org.osmdroid", name = "osmdroid-android", version.ref = "osmdroid-android" }
|
||||
recyclerview = { group = "androidx.recyclerview", name = "recyclerview", version.ref = "recyclerview" }
|
||||
|
@ -3,11 +3,15 @@ package me.rhunk.snapenhance.mapper.impl
|
||||
import me.rhunk.snapenhance.mapper.AbstractClassMapper
|
||||
import me.rhunk.snapenhance.mapper.ext.findConstString
|
||||
import me.rhunk.snapenhance.mapper.ext.getClassName
|
||||
import me.rhunk.snapenhance.mapper.ext.isAbstract
|
||||
import me.rhunk.snapenhance.mapper.ext.isEnum
|
||||
import java.lang.reflect.Modifier
|
||||
|
||||
class FriendRelationshipChangerMapper : AbstractClassMapper("FriendRelationshipChanger") {
|
||||
val classReference = classReference("class")
|
||||
val addFriendMethod = string("addFriendMethod")
|
||||
|
||||
val removeFriendClass = classReference("removeFriendClass")
|
||||
val removeFriendMethod = string("removeFriendMethod")
|
||||
|
||||
init {
|
||||
@ -22,22 +26,29 @@ class FriendRelationshipChangerMapper : AbstractClassMapper("FriendRelationshipC
|
||||
it.parameters[4].type == "Ljava/lang/String;"
|
||||
}
|
||||
|
||||
val removeFriendDexMethod = classDef.methods.firstOrNull {
|
||||
it.parameterTypes.size == 5 &&
|
||||
it.parameterTypes[0] == "Ljava/lang/String;" &&
|
||||
getClass(it.parameterTypes[1])?.isEnum() == true &&
|
||||
it.parameterTypes[2] == "Ljava/lang/String;" &&
|
||||
it.parameterTypes[3] == "Ljava/lang/String;"
|
||||
}
|
||||
|
||||
this@FriendRelationshipChangerMapper.apply {
|
||||
classReference.set(classDef.getClassName())
|
||||
addFriendMethod.set(addFriendDexMethod.name)
|
||||
removeFriendMethod.set(removeFriendDexMethod?.name)
|
||||
}
|
||||
|
||||
return@mapper
|
||||
}
|
||||
}
|
||||
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
|
||||
|
||||
removeFriendClass.set(classDef.getClassName())
|
||||
removeFriendMethod.set(removeFriendDexMethod.name)
|
||||
return@mapper
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -3,8 +3,7 @@ package me.rhunk.snapenhance.mapper.tests
|
||||
import com.google.gson.GsonBuilder
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import me.rhunk.snapenhance.mapper.ClassMapper
|
||||
import me.rhunk.snapenhance.mapper.impl.*
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user