mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
Shamrock
: ローカルキャッシュメッセージの削除をサポート
This commit is contained in:
parent
72600364ff
commit
3988ad3811
@ -0,0 +1,5 @@
|
|||||||
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
public interface IClearMsgRecordsCallback {
|
||||||
|
void onResult(int code, String reason, long lastMsgId);
|
||||||
|
}
|
@ -16,7 +16,11 @@ public interface IKernelMsgService {
|
|||||||
|
|
||||||
void addLocalRecordMsg(Contact contact, long msgId, MsgElement elem, HashMap<Integer, MsgAttributeInfo> hashMap, boolean z, IOperateCallback callback);
|
void addLocalRecordMsg(Contact contact, long msgId, MsgElement elem, HashMap<Integer, MsgAttributeInfo> hashMap, boolean z, IOperateCallback callback);
|
||||||
|
|
||||||
void getMultiMsg(Contact contact, long msgId, long uniseq, IGetMultiMsgCallback cb);
|
void getMultiMsg(Contact contact, long rootMsgId, long parentMsgId, IGetMultiMsgCallback cb);
|
||||||
|
|
||||||
|
void clearMsgRecords(Contact contact, IClearMsgRecordsCallback cb);
|
||||||
|
|
||||||
|
String createUidFromTinyId(long j2, long j3);
|
||||||
|
|
||||||
void switchBackGround(BackGroundInfo backGroundInfo, IOperateCallback cb);
|
void switchBackGround(BackGroundInfo backGroundInfo, IOperateCallback cb);
|
||||||
|
|
||||||
|
@ -52,7 +52,9 @@ internal object MessageConvert {
|
|||||||
MsgConstant.KELEMTYPEARKSTRUCT to MessageElemConverter.StructJsonConverter,
|
MsgConstant.KELEMTYPEARKSTRUCT to MessageElemConverter.StructJsonConverter,
|
||||||
MsgConstant.KELEMTYPEREPLY to MessageElemConverter.ReplyConverter,
|
MsgConstant.KELEMTYPEREPLY to MessageElemConverter.ReplyConverter,
|
||||||
MsgConstant.KELEMTYPEGRAYTIP to MessageElemConverter.GrayTipsConverter,
|
MsgConstant.KELEMTYPEGRAYTIP to MessageElemConverter.GrayTipsConverter,
|
||||||
MsgConstant.KELEMTYPEFILE to MessageElemConverter.FileConverter
|
MsgConstant.KELEMTYPEFILE to MessageElemConverter.FileConverter,
|
||||||
|
MsgConstant.KELEMTYPEMULTIFORWARD to MessageElemConverter.XmlMultiMsgConverter,
|
||||||
|
MsgConstant.KELEMTYPESTRUCTLONGMSG to MessageElemConverter.XmlLongMsgConverter,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package moe.fuqiuluo.qqinterface.servlet.msg.convert
|
|||||||
|
|
||||||
import com.tencent.qqnt.kernel.nativeinterface.MsgConstant
|
import com.tencent.qqnt.kernel.nativeinterface.MsgConstant
|
||||||
import com.tencent.qqnt.kernel.nativeinterface.MsgElement
|
import com.tencent.qqnt.kernel.nativeinterface.MsgElement
|
||||||
import moe.fuqiuluo.qqinterface.servlet.MsgSvc
|
|
||||||
import moe.fuqiuluo.qqinterface.servlet.transfile.RichProtoSvc
|
import moe.fuqiuluo.qqinterface.servlet.transfile.RichProtoSvc
|
||||||
import moe.fuqiuluo.shamrock.helper.ContactHelper
|
import moe.fuqiuluo.shamrock.helper.ContactHelper
|
||||||
import moe.fuqiuluo.shamrock.helper.Level
|
import moe.fuqiuluo.shamrock.helper.Level
|
||||||
@ -195,6 +194,15 @@ internal sealed class MessageElemConverter: IMessageConvert {
|
|||||||
): MessageSegment {
|
): MessageSegment {
|
||||||
val data = element.arkElement.bytesData.asJsonObject
|
val data = element.arkElement.bytesData.asJsonObject
|
||||||
return when (data["app"].asString) {
|
return when (data["app"].asString) {
|
||||||
|
"com.tencent.multimsg" -> {
|
||||||
|
val info = data["meta"].asJsonObject["detail"].asJsonObject
|
||||||
|
MessageSegment(
|
||||||
|
type = "forward",
|
||||||
|
data = mapOf(
|
||||||
|
"id" to info["resid"].asString
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
"com.tencent.troopsharecard" -> {
|
"com.tencent.troopsharecard" -> {
|
||||||
val info = data["meta"].asJsonObject["contact"].asJsonObject
|
val info = data["meta"].asJsonObject["contact"].asJsonObject
|
||||||
MessageSegment(
|
MessageSegment(
|
||||||
@ -230,7 +238,7 @@ internal sealed class MessageElemConverter: IMessageConvert {
|
|||||||
else -> MessageSegment(
|
else -> MessageSegment(
|
||||||
type = "json",
|
type = "json",
|
||||||
data = mapOf(
|
data = mapOf(
|
||||||
"data" to element.arkElement.bytesData.asJsonObject
|
"data" to element.arkElement.bytesData.asJsonObject.toString()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -317,6 +325,41 @@ internal sealed class MessageElemConverter: IMessageConvert {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 老板QQ的合并转发信息
|
||||||
|
*/
|
||||||
|
object XmlMultiMsgConverter: MessageElemConverter() {
|
||||||
|
override suspend fun convert(
|
||||||
|
chatType: Int,
|
||||||
|
peerId: String,
|
||||||
|
element: MsgElement
|
||||||
|
): MessageSegment {
|
||||||
|
val multiMsg = element.multiForwardMsgElement
|
||||||
|
return MessageSegment(
|
||||||
|
type = "forward",
|
||||||
|
data = mapOf(
|
||||||
|
"id" to multiMsg.resId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object XmlLongMsgConverter: MessageElemConverter() {
|
||||||
|
override suspend fun convert(
|
||||||
|
chatType: Int,
|
||||||
|
peerId: String,
|
||||||
|
element: MsgElement
|
||||||
|
): MessageSegment {
|
||||||
|
val longMsg = element.structLongMsgElement
|
||||||
|
return MessageSegment(
|
||||||
|
type = "forward",
|
||||||
|
data = mapOf(
|
||||||
|
"id" to longMsg.resId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected fun unknownChatType(chatType: Int) {
|
protected fun unknownChatType(chatType: Int) {
|
||||||
throw UnsupportedOperationException("Not supported chat type: $chatType")
|
throw UnsupportedOperationException("Not supported chat type: $chatType")
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,7 @@ internal object HTTPServer {
|
|||||||
weatherAction()
|
weatherAction()
|
||||||
otherAction()
|
otherAction()
|
||||||
guildAction()
|
guildAction()
|
||||||
|
testAction()
|
||||||
if (ShamrockConfig.isDev()) {
|
if (ShamrockConfig.isDev()) {
|
||||||
qsign()
|
qsign()
|
||||||
obtainProtocolData()
|
obtainProtocolData()
|
||||||
|
@ -33,6 +33,7 @@ internal object ActionManager {
|
|||||||
|
|
||||||
// MSG ACTIONS
|
// MSG ACTIONS
|
||||||
SendMessage, DeleteMessage, GetMsg, GetForwardMsg, SendGroupForwardMsg, SendGroupMessage, SendPrivateMessage,
|
SendMessage, DeleteMessage, GetMsg, GetForwardMsg, SendGroupForwardMsg, SendGroupMessage, SendPrivateMessage,
|
||||||
|
ClearMsgs,
|
||||||
|
|
||||||
// RESOURCE ACTION
|
// RESOURCE ACTION
|
||||||
GetRecord, GetImage, UploadGroupFile, CreateGroupFileFolder, DeleteGroupFolder,
|
GetRecord, GetImage, UploadGroupFile, CreateGroupFileFolder, DeleteGroupFolder,
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
package moe.fuqiuluo.shamrock.remote.action.handlers
|
||||||
|
|
||||||
|
import kotlinx.serialization.json.JsonElement
|
||||||
|
import moe.fuqiuluo.shamrock.helper.MessageHelper
|
||||||
|
import moe.fuqiuluo.shamrock.remote.action.ActionSession
|
||||||
|
import moe.fuqiuluo.shamrock.remote.action.IActionHandler
|
||||||
|
import moe.fuqiuluo.shamrock.tools.EmptyJsonString
|
||||||
|
import moe.fuqiuluo.shamrock.xposed.helper.NTServiceFetcher
|
||||||
|
|
||||||
|
internal object ClearMsgs: IActionHandler() {
|
||||||
|
override suspend fun internalHandle(session: ActionSession): String {
|
||||||
|
val msgType = session.getString("message_type")
|
||||||
|
val peerId = session.getString(if (msgType == "group") "group_id" else "user_id")
|
||||||
|
return invoke(msgType, peerId, session.echo)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend operator fun invoke(
|
||||||
|
msgType: String,
|
||||||
|
peerId: String,
|
||||||
|
echo: JsonElement = EmptyJsonString
|
||||||
|
): String {
|
||||||
|
val chatType = MessageHelper.obtainMessageTypeByDetailType(msgType)
|
||||||
|
val contact = MessageHelper.generateContact(chatType, peerId, "")
|
||||||
|
NTServiceFetcher.kernelService.wrapperSession.msgService.clearMsgRecords(contact, null)
|
||||||
|
return ok(echo = echo)
|
||||||
|
}
|
||||||
|
|
||||||
|
override val requiredParams: Array<String>
|
||||||
|
get() = arrayOf("message_type")
|
||||||
|
|
||||||
|
override fun path(): String = "clear_msgs"
|
||||||
|
}
|
@ -12,6 +12,8 @@ internal object GetForwardMsg: IActionHandler() {
|
|||||||
val sessionService = kernelService.wrapperSession
|
val sessionService = kernelService.wrapperSession
|
||||||
val msgService = sessionService.msgService
|
val msgService = sessionService.msgService
|
||||||
|
|
||||||
|
//msgService.getMultiMsg()
|
||||||
|
|
||||||
return error("不支持实现,请提交ISSUE!", session.echo)
|
return error("不支持实现,请提交ISSUE!", session.echo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,12 @@ import moe.fuqiuluo.shamrock.tools.isJsonData
|
|||||||
import moe.fuqiuluo.shamrock.tools.isJsonString
|
import moe.fuqiuluo.shamrock.tools.isJsonString
|
||||||
|
|
||||||
fun Routing.messageAction() {
|
fun Routing.messageAction() {
|
||||||
|
getOrPost("/clear_msgs") {
|
||||||
|
val msgType = fetchOrThrow("message_type")
|
||||||
|
val peerId = fetchOrThrow(if (msgType == "group") "group_id" else "user_id")
|
||||||
|
call.respondText(ClearMsgs(msgType, peerId))
|
||||||
|
}
|
||||||
|
|
||||||
getOrPost("/delete_msg") {
|
getOrPost("/delete_msg") {
|
||||||
val msgHash = fetchOrThrow("message_id").toInt()
|
val msgHash = fetchOrThrow("message_id").toInt()
|
||||||
call.respondText(DeleteMessage(msgHash))
|
call.respondText(DeleteMessage(msgHash))
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
package moe.fuqiuluo.shamrock.remote.api
|
||||||
|
|
||||||
|
import io.ktor.server.application.call
|
||||||
|
import io.ktor.server.response.respondText
|
||||||
|
import io.ktor.server.routing.Routing
|
||||||
|
import io.ktor.server.routing.get
|
||||||
|
import moe.fuqiuluo.shamrock.tools.fetch
|
||||||
|
import moe.fuqiuluo.shamrock.tools.fetchOrThrow
|
||||||
|
import moe.fuqiuluo.shamrock.xposed.helper.NTServiceFetcher
|
||||||
|
|
||||||
|
fun Routing.testAction() {
|
||||||
|
|
||||||
|
get("/test/createUidFromTinyId") {
|
||||||
|
val selfId = fetchOrThrow("selfId").toLong()
|
||||||
|
val peerId = fetchOrThrow("peerId").toLong()
|
||||||
|
call.respondText(NTServiceFetcher.kernelService.wrapperSession.msgService.createUidFromTinyId(selfId, peerId))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user