refactor: ProfilePictureDownloader

This commit is contained in:
rhunk 2023-12-31 15:56:41 +01:00
parent dd755af5be
commit 1b566db184

View File

@ -59,15 +59,8 @@ class ProfilePictureDownloader : Feature("ProfilePictureDownloader", loadParams
context.event.subscribe(NetworkApiRequestEvent::class) { event -> context.event.subscribe(NetworkApiRequestEvent::class) { event ->
if (!event.url.endsWith("/rpc/getPublicProfile")) return@subscribe if (!event.url.endsWith("/rpc/getPublicProfile")) return@subscribe
Hooker.ephemeralHookObjectMethod(event.callback::class.java, event.callback, "onSucceeded", HookStage.BEFORE) { methodParams -> event.onSuccess { buffer ->
val content = methodParams.arg<ByteBuffer>(2).run { ProtoReader(buffer ?: return@onSuccess).followPath(1, 1, 2) {
ByteArray(capacity()).also {
get(it)
position(0)
}
}
ProtoReader(content).followPath(1, 1, 2) {
friendUsername = getString(2) ?: return@followPath friendUsername = getString(2) ?: return@followPath
followPath(4) { followPath(4) {
backgroundUrl = getString(2) backgroundUrl = getString(2)