mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
Shamrock
: fix wrong group request event
This commit is contained in:
parent
89154f0c49
commit
03d62c55c2
@ -600,7 +600,15 @@ internal object GroupSvc: BaseSvc() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ProfileService.Pb.ReqSystemMsgAction.Group
|
// ProfileService.Pb.ReqSystemMsgAction.Group
|
||||||
suspend fun requestGroupRequest(msgSeq: Long, uin: Long, gid: Long, msg: String? = "", approve: Boolean? = true, notSee: Boolean? = false): Result<String>{
|
suspend fun requestGroupRequest(
|
||||||
|
msgSeq: Long,
|
||||||
|
uin: Long,
|
||||||
|
gid: Long,
|
||||||
|
msg: String? = "",
|
||||||
|
approve: Boolean? = true,
|
||||||
|
notSee: Boolean? = false,
|
||||||
|
subType: String
|
||||||
|
): Result<String>{
|
||||||
// val app = AppRuntimeFetcher.appRuntime
|
// val app = AppRuntimeFetcher.appRuntime
|
||||||
// if (app !is AppInterface)
|
// if (app !is AppInterface)
|
||||||
// throw RuntimeException("AppRuntime cannot cast to AppInterface")
|
// throw RuntimeException("AppRuntime cannot cast to AppInterface")
|
||||||
@ -617,7 +625,26 @@ internal object GroupSvc: BaseSvc() {
|
|||||||
// app
|
// app
|
||||||
// )
|
// )
|
||||||
// 实在找不到接口了 发pb吧
|
// 实在找不到接口了 发pb吧
|
||||||
val buffer = protobufOf(
|
val buffer: ByteArray
|
||||||
|
when (subType) {
|
||||||
|
"invite" -> {
|
||||||
|
buffer = protobufOf(
|
||||||
|
1 to 1,
|
||||||
|
2 to msgSeq,
|
||||||
|
3 to uin, // self
|
||||||
|
4 to 1,
|
||||||
|
5 to 3,
|
||||||
|
6 to 10016,
|
||||||
|
7 to 2,
|
||||||
|
8 to mapOf(
|
||||||
|
1 to if (approve != false) 11 else 12,
|
||||||
|
2 to gid
|
||||||
|
),
|
||||||
|
9 to 1000
|
||||||
|
).toByteArray()
|
||||||
|
}
|
||||||
|
"add" -> {
|
||||||
|
buffer = protobufOf(
|
||||||
1 to 2,
|
1 to 2,
|
||||||
2 to msgSeq,
|
2 to msgSeq,
|
||||||
3 to uin,
|
3 to uin,
|
||||||
@ -631,6 +658,11 @@ internal object GroupSvc: BaseSvc() {
|
|||||||
),
|
),
|
||||||
9 to 1000
|
9 to 1000
|
||||||
).toByteArray()
|
).toByteArray()
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
return Result.failure(Exception("不支持的sub_type"))
|
||||||
|
}
|
||||||
|
}
|
||||||
val respBuffer = sendBufferAW("ProfileService.Pb.ReqSystemMsgAction.Group", true, buffer)
|
val respBuffer = sendBufferAW("ProfileService.Pb.ReqSystemMsgAction.Group", true, buffer)
|
||||||
?: return Result.failure(Exception("操作失败"))
|
?: return Result.failure(Exception("操作失败"))
|
||||||
val result = ProtoUtils.decodeFromByteArray(respBuffer.slice(4))
|
val result = ProtoUtils.decodeFromByteArray(respBuffer.slice(4))
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package moe.fuqiuluo.shamrock.remote.action.handlers
|
package moe.fuqiuluo.shamrock.remote.action.handlers
|
||||||
|
|
||||||
import kotlinx.serialization.json.JsonElement
|
import kotlinx.serialization.json.JsonElement
|
||||||
import moe.fuqiuluo.qqinterface.servlet.FriendSvc
|
|
||||||
import moe.fuqiuluo.qqinterface.servlet.GroupSvc
|
import moe.fuqiuluo.qqinterface.servlet.GroupSvc
|
||||||
import moe.fuqiuluo.shamrock.remote.action.ActionSession
|
import moe.fuqiuluo.shamrock.remote.action.ActionSession
|
||||||
import moe.fuqiuluo.shamrock.remote.action.IActionHandler
|
import moe.fuqiuluo.shamrock.remote.action.IActionHandler
|
||||||
import moe.fuqiuluo.shamrock.remote.service.data.push.NoticeSubType
|
|
||||||
import moe.fuqiuluo.shamrock.tools.EmptyJsonString
|
import moe.fuqiuluo.shamrock.tools.EmptyJsonString
|
||||||
|
|
||||||
internal object SetGroupAddRequest: IActionHandler() {
|
internal object SetGroupAddRequest: IActionHandler() {
|
||||||
@ -22,9 +20,9 @@ internal object SetGroupAddRequest: IActionHandler() {
|
|||||||
val flags = flag.split(";")
|
val flags = flag.split(";")
|
||||||
val ts = flags[0].toLong()
|
val ts = flags[0].toLong()
|
||||||
val groupCode = flags[1].toLong()
|
val groupCode = flags[1].toLong()
|
||||||
val applier = flags[2].toLong()
|
val uin = flags[2].toLong()
|
||||||
return try {
|
return try {
|
||||||
val result = GroupSvc.requestGroupRequest(ts, applier, groupCode, remark ?: "", approve, notSeen)
|
val result = GroupSvc.requestGroupRequest(ts, uin, groupCode, remark ?: "", approve, notSeen, subType)
|
||||||
if (result.isSuccess) {
|
if (result.isSuccess) {
|
||||||
ok(result.getOrNull(), echo)
|
ok(result.getOrNull(), echo)
|
||||||
} else {
|
} else {
|
||||||
|
@ -27,11 +27,11 @@ fun Routing.requestRouter() {
|
|||||||
val flag = fetchOrThrow("flag")
|
val flag = fetchOrThrow("flag")
|
||||||
val approve = fetchOrNull("approve")?.toBooleanStrict() ?: true
|
val approve = fetchOrNull("approve")?.toBooleanStrict() ?: true
|
||||||
val remark = fetchOrNull("reason")
|
val remark = fetchOrNull("reason")
|
||||||
val subType = fetchOrNull("sub_type")
|
val subType = fetchOrThrow("sub_type")
|
||||||
val notSeen = fetchOrNull("not_seen")?.toBooleanStrict() ?: false
|
val notSeen = fetchOrNull("not_seen")?.toBooleanStrict() ?: false
|
||||||
|
|
||||||
call.respondText(
|
call.respondText(
|
||||||
SetGroupAddRequest(flag, approve, subType ?: "add", remark, notSeen),
|
SetGroupAddRequest(flag, approve, subType, remark, notSeen),
|
||||||
ContentType.Application.Json
|
ContentType.Application.Json
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,7 @@ internal object PrimitiveListener {
|
|||||||
34 -> onGroupMemberDecreased(msgTime, pb)
|
34 -> onGroupMemberDecreased(msgTime, pb)
|
||||||
44 -> onGroupAdminChange(msgTime, pb)
|
44 -> onGroupAdminChange(msgTime, pb)
|
||||||
84 -> onGroupApply(msgTime, pb)
|
84 -> onGroupApply(msgTime, pb)
|
||||||
|
87 -> onInviteGroup(msgTime, pb)
|
||||||
528 -> when(subType) {
|
528 -> when(subType) {
|
||||||
35 -> onFriendApply(msgTime, pb)
|
35 -> onFriendApply(msgTime, pb)
|
||||||
// invite
|
// invite
|
||||||
@ -337,13 +338,12 @@ internal object PrimitiveListener {
|
|||||||
val applierUid = pb[1, 3, 2, 3].asUtf8String
|
val applierUid = pb[1, 3, 2, 3].asUtf8String
|
||||||
val reason = pb[1, 3, 2, 5].asUtf8String
|
val reason = pb[1, 3, 2, 5].asUtf8String
|
||||||
val applier = ContactHelper.getUinByUidAsync(applierUid).toLong()
|
val applier = ContactHelper.getUinByUidAsync(applierUid).toLong()
|
||||||
val msg_time = pb[1, 2, 6].asLong
|
|
||||||
|
|
||||||
LogCenter.log("$msg_time 入群申请($groupCode) $applier: \"$reason\"")
|
LogCenter.log("入群申请($groupCode) $applier: \"$reason\"")
|
||||||
try {
|
try {
|
||||||
val reqs = requestGroupSystemMsgNew(20, 0, 0)
|
val reqs = requestGroupSystemMsgNew(20, 0, 0)
|
||||||
val req = reqs?.first {
|
val req = reqs?.first {
|
||||||
it.msg_time.get() == msg_time
|
it.msg_time.get() == time
|
||||||
}
|
}
|
||||||
val seq = req?.msg_seq?.get()
|
val seq = req?.msg_seq?.get()
|
||||||
val flag = "$seq;$groupCode;$applierUid"
|
val flag = "$seq;$groupCode;$applierUid"
|
||||||
@ -363,18 +363,21 @@ internal object PrimitiveListener {
|
|||||||
val groupCode = pb[1, 3, 2, 2, 3].asULong
|
val groupCode = pb[1, 3, 2, 2, 3].asULong
|
||||||
val applierUid = pb[1, 3, 2, 2, 5].asUtf8String
|
val applierUid = pb[1, 3, 2, 2, 5].asUtf8String
|
||||||
val applier = ContactHelper.getUinByUidAsync(applierUid).toLong()
|
val applier = ContactHelper.getUinByUidAsync(applierUid).toLong()
|
||||||
val msg_time = pb[1, 2, 6].asLong
|
if (pb[1, 3, 2, 2, 1].asInt < 3) {
|
||||||
|
// todo
|
||||||
|
return
|
||||||
|
}
|
||||||
LogCenter.log("邀请入群申请($groupCode): $applier")
|
LogCenter.log("邀请入群申请($groupCode): $applier")
|
||||||
try {
|
try {
|
||||||
val reqs = requestGroupSystemMsgNew(20, 0, 0)
|
val reqs = requestGroupSystemMsgNew(20, 0, 0)
|
||||||
val req = reqs?.first {
|
val req = reqs?.first {
|
||||||
it.msg_time.get() == msg_time
|
it.msg_time.get() == time
|
||||||
}
|
}
|
||||||
val seq = req?.msg_seq?.get()
|
val seq = req?.msg_seq?.get()
|
||||||
val flag = "$seq;$groupCode;$applierUid"
|
val flag = "$seq;$groupCode;$applierUid"
|
||||||
if(!seq?.let {
|
if(!seq?.let {
|
||||||
GlobalEventTransmitter.GroupNoticeTransmitter
|
GlobalEventTransmitter.GroupNoticeTransmitter
|
||||||
.transGroupApply(it, applier, "", groupCode, flag, NoticeSubType.Invite)
|
.transGroupApply(it, applier, "", groupCode, flag, NoticeSubType.Add)
|
||||||
}!!) {
|
}!!) {
|
||||||
LogCenter.log("邀请入群申请推送失败!", Level.WARN)
|
LogCenter.log("邀请入群申请推送失败!", Level.WARN)
|
||||||
}
|
}
|
||||||
@ -386,4 +389,29 @@ internal object PrimitiveListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private suspend fun onInviteGroup(time: Long, pb: ProtoMap) {
|
||||||
|
val groupCode = pb[1, 3, 2, 1].asULong
|
||||||
|
val invitorUid = pb[1, 3, 2, 5].asUtf8String
|
||||||
|
val invitor = ContactHelper.getUinByUidAsync(invitorUid).toLong()
|
||||||
|
val uin = pb[1, 1, 5].asLong
|
||||||
|
LogCenter.log("邀请入群$groupCode 邀请者: \"$invitor\"")
|
||||||
|
try {
|
||||||
|
val reqs = requestGroupSystemMsgNew(20, 0, 0)
|
||||||
|
val req = reqs?.first {
|
||||||
|
it.msg_time.get() == time
|
||||||
|
}
|
||||||
|
val seq = req?.msg_seq?.get()
|
||||||
|
val flag = "$seq;$groupCode;$uin"
|
||||||
|
if(!seq?.let {
|
||||||
|
GlobalEventTransmitter.GroupNoticeTransmitter
|
||||||
|
.transGroupApply(it, invitor, "", groupCode, flag, NoticeSubType.Invite)
|
||||||
|
}!!) {
|
||||||
|
LogCenter.log("邀请入群推送失败!", Level.WARN)
|
||||||
|
}
|
||||||
|
} catch (err: Throwable) {
|
||||||
|
LogCenter.log("邀请入群推送失败!", Level.WARN)
|
||||||
|
LogCenter.log(err.stackTraceToString(), Level.ERROR)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user