Skip to content

Commit 01c0158

Browse files
committed
fix:Fixed the issue of anti-recall offline message synchronization
1 parent a29a59b commit 01c0158

File tree

2 files changed

+45
-21
lines changed

2 files changed

+45
-21
lines changed

app/build.gradle.kts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ android {
1717
applicationId = BuildVersionConfig.applicationId
1818
minSdk = BuildVersionConfig.minSdk
1919
targetSdk = BuildVersionConfig.targetSdk
20-
versionCode = 27
21-
versionName = "2.7"
20+
versionCode = 28
21+
versionName = "2.8"
2222

2323
ndk {
2424
//只支持arm64 v8a的lib so库,因为qq只支持arm64 v8a
@@ -144,8 +144,6 @@ dependencies {
144144
implementation(libs.kotlinx.serialization.protobuf)
145145
implementation(libs.protobuf.java)
146146

147-
// implementation(project(":DialogX"))
148-
// implementation(project(":DialogXMaterialYou"))
149147
}
150148
protobuf {
151149
protoc {

app/src/main/java/top/sacz/timtool/hook/item/chat/retracting/PreventRetractingMessageCore.kt

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,49 @@ object PreventRetractingMessageCore {
1818

1919
fun handleInfoSyncPush(buffer: ByteArray, param: XC_MethodHook.MethodHookParam) {
2020
val infoSyncPush = InfoSyncPushOuterClass.InfoSyncPush.parseFrom(buffer)
21-
infoSyncPush.syncRecallContent.syncInfoBodyList.forEach { syncInfoBody ->
22-
syncInfoBody.msgList.forEach { qqMessage ->
23-
val msgType = qqMessage.messageContentInfo.msgType
24-
val msgSubType = qqMessage.messageContentInfo.msgSubType
25-
if ((msgType == 732 && msgSubType == 17) || (msgType == 528 && msgSubType == 138)) {
26-
val newInfoSyncPush = infoSyncPush.toBuilder().apply {
27-
syncRecallContent = syncRecallContent.toBuilder().apply {
28-
for (i in 0 until syncInfoBodyCount) {
29-
setSyncInfoBody(
30-
i, getSyncInfoBody(i).toBuilder().clearMsg().build()
31-
)
32-
}
33-
}.build()
34-
}.build()
35-
param.args[1] = newInfoSyncPush.toByteArray()
21+
val recallMsgSeqList = mutableListOf<Pair<String, Int>>()
22+
//新代码 构建新的InfoSyncPush
23+
val newInfoSyncPush = infoSyncPush.toBuilder().apply {
24+
syncRecallContent = syncRecallContent.toBuilder().apply {
25+
syncInfoBodyList.forEachIndexed { index, syncInfoBody ->
26+
val newMsgList = syncInfoBody.msgList.filter { qqMessage ->
27+
val msgType = qqMessage.messageContentInfo.msgType
28+
val msgSubType = qqMessage.messageContentInfo.msgSubType
29+
val isRecall =
30+
(msgType == 732 && msgSubType == 17) || (msgType == 528 && msgSubType == 138)
31+
//是私聊消息
32+
if (msgType == 528 && msgSubType == 138) {
33+
val opInfo = qqMessage.messageBody.operationInfo
34+
val c2cRecall = C2CRecallOperationInfo
35+
.parseFrom(opInfo)
36+
val msgSeq = c2cRecall.info.msgSeq
37+
val senderUid = qqMessage.messageHead.senderUid
38+
recallMsgSeqList.add(senderUid to msgSeq)
39+
} else if (msgType == 732 && msgSubType == 17) {
40+
//群聊消息
41+
val opInfo = qqMessage.messageBody.operationInfo
42+
val groupRecall =
43+
QQMessageOuterClass.QQMessage.MessageBody.GroupRecallOperationInfo
44+
.parseFrom(opInfo)
45+
//groupUin
46+
val groupPeerId = groupRecall.peerId.toString()
47+
//msg seq
48+
val recallMsgSeq = groupRecall.info.msgInfo.msgSeq
49+
recallMsgSeqList.add(groupPeerId to recallMsgSeq)
50+
}
51+
!isRecall
52+
}
53+
setSyncInfoBody(
54+
index,
55+
syncInfoBody.toBuilder().clearMsg().addAllMsg(newMsgList).build()
56+
)
3657
}
37-
}
58+
}.build()
59+
}.build()
60+
param.args[1] = newInfoSyncPush.toByteArray()
61+
val retracting = HookItemFactory.getItem(PreventRetractingMessage::class.java)
62+
recallMsgSeqList.forEach { (peerId, msgSeq) ->
63+
retracting.writeAndRefresh(peerId, msgSeq)
3864
}
3965
}
4066

@@ -134,4 +160,4 @@ object PreventRetractingMessageCore {
134160

135161
}
136162

137-
}
163+
}

0 commit comments

Comments
 (0)