mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
feat: グループに参加して友達と一緒に通知を申請しましょう
This commit is contained in:
parent
bd28b0f7f7
commit
8a4212ffd7
@ -311,6 +311,27 @@ internal object GlobalEventTransmitter: BaseSvc() {
|
|||||||
))
|
))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun transGroupApply(
|
||||||
|
time: Long,
|
||||||
|
operator: Long,
|
||||||
|
reason: String,
|
||||||
|
groupCode: Long,
|
||||||
|
subType: NoticeSubType
|
||||||
|
): Boolean {
|
||||||
|
pushNotice(NoticeEvent(
|
||||||
|
time = time,
|
||||||
|
selfId = app.longAccountUin,
|
||||||
|
postType = PostType.Notice,
|
||||||
|
type = NoticeType.GroupApply,
|
||||||
|
operatorId = operator,
|
||||||
|
tip = reason,
|
||||||
|
groupId = groupCode,
|
||||||
|
subType = subType
|
||||||
|
))
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -338,7 +359,6 @@ internal object GlobalEventTransmitter: BaseSvc() {
|
|||||||
selfId = app.longAccountUin,
|
selfId = app.longAccountUin,
|
||||||
postType = PostType.Notice,
|
postType = PostType.Notice,
|
||||||
type = NoticeType.FriendRecall,
|
type = NoticeType.FriendRecall,
|
||||||
subType = NoticeSubType.Poke,
|
|
||||||
operatorId = operation,
|
operatorId = operation,
|
||||||
userId = operation,
|
userId = operation,
|
||||||
msgId = msgHashId,
|
msgId = msgHashId,
|
||||||
@ -346,6 +366,19 @@ internal object GlobalEventTransmitter: BaseSvc() {
|
|||||||
))
|
))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun transFriendApply(time: Long, operation: Long, tipText: String): Boolean {
|
||||||
|
pushNotice(NoticeEvent(
|
||||||
|
time = time,
|
||||||
|
selfId = app.longAccountUin,
|
||||||
|
postType = PostType.Notice,
|
||||||
|
type = NoticeType.FriendApply,
|
||||||
|
operatorId = operation,
|
||||||
|
userId = operation,
|
||||||
|
tip = tipText
|
||||||
|
))
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ShamrockDsl
|
@ShamrockDsl
|
||||||
|
@ -10,7 +10,9 @@ internal enum class NoticeType {
|
|||||||
@SerialName("group_decrease") GroupMemDecrease,
|
@SerialName("group_decrease") GroupMemDecrease,
|
||||||
@SerialName("group_increase") GroupMemIncrease,
|
@SerialName("group_increase") GroupMemIncrease,
|
||||||
@SerialName("group_recall") GroupRecall,
|
@SerialName("group_recall") GroupRecall,
|
||||||
|
@SerialName("group_apply") GroupApply,
|
||||||
@SerialName("friend_recall") FriendRecall,
|
@SerialName("friend_recall") FriendRecall,
|
||||||
|
@SerialName("friend_add") FriendApply,
|
||||||
@SerialName("notify") Notify,
|
@SerialName("notify") Notify,
|
||||||
@SerialName("group_upload") GroupUpload,
|
@SerialName("group_upload") GroupUpload,
|
||||||
@SerialName("private_upload") PrivateUpload
|
@SerialName("private_upload") PrivateUpload
|
||||||
@ -26,6 +28,7 @@ internal enum class NoticeSubType {
|
|||||||
@SerialName("set") Set,
|
@SerialName("set") Set,
|
||||||
@SerialName("un_set") UnSet,
|
@SerialName("un_set") UnSet,
|
||||||
|
|
||||||
|
@SerialName("add") Add,
|
||||||
@SerialName("invite") Invite,
|
@SerialName("invite") Invite,
|
||||||
@SerialName("approve") Approve,
|
@SerialName("approve") Approve,
|
||||||
@SerialName("leave") Leave,
|
@SerialName("leave") Leave,
|
||||||
|
@ -60,7 +60,11 @@ internal object PrimitiveListener {
|
|||||||
33 -> onGroupMemIncreased(msgTime, pb)
|
33 -> onGroupMemIncreased(msgTime, pb)
|
||||||
34 -> onGroupMemberDecreased(msgTime, pb)
|
34 -> onGroupMemberDecreased(msgTime, pb)
|
||||||
44 -> onGroupAdminChange(msgTime, pb)
|
44 -> onGroupAdminChange(msgTime, pb)
|
||||||
|
84 -> onGroupApply(msgTime, pb)
|
||||||
528 -> when(subType) {
|
528 -> when(subType) {
|
||||||
|
35 -> onFriendApply(msgTime, pb)
|
||||||
|
// invite
|
||||||
|
68 -> onGroupApply(msgTime, pb)
|
||||||
138 -> onC2CRecall(msgTime, pb)
|
138 -> onC2CRecall(msgTime, pb)
|
||||||
290 -> onC2cPoke(msgTime, pb)
|
290 -> onC2cPoke(msgTime, pb)
|
||||||
}
|
}
|
||||||
@ -102,6 +106,22 @@ internal object PrimitiveListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private suspend fun onFriendApply(msgTime: Long, pb: ProtoMap) {
|
||||||
|
val applierUid = pb[1, 3, 2, 1, 2].asUtf8String
|
||||||
|
val msg = pb[1, 3, 2, 1, 10].asUtf8String
|
||||||
|
val source = pb[1, 3, 2, 1, 11].asUtf8String
|
||||||
|
var applier = ContactHelper.getUinByUidAsync(applierUid).toLong()
|
||||||
|
if (applier == 0L) {
|
||||||
|
applier = pb[4, 3, 8].asLong
|
||||||
|
}
|
||||||
|
LogCenter.log("来自$applier 的好友申请:$msg ($source)")
|
||||||
|
if(!GlobalEventTransmitter.PrivateNoticeTransmitter
|
||||||
|
.transFriendApply(msgTime, applier, msg)) {
|
||||||
|
LogCenter.log("好友申请推送失败!", Level.WARN)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private suspend fun onGroupPoke(time: Long, pb: ProtoMap) {
|
private suspend fun onGroupPoke(time: Long, pb: ProtoMap) {
|
||||||
val groupCode1 = pb[1, 1, 1].asULong
|
val groupCode1 = pb[1, 1, 1].asULong
|
||||||
|
|
||||||
@ -296,4 +316,32 @@ internal object PrimitiveListener {
|
|||||||
readPacket.release()
|
readPacket.release()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private suspend fun onGroupApply(time: Long, pb: ProtoMap) {
|
||||||
|
when(pb[1, 2, 1].asInt) {
|
||||||
|
84 -> {
|
||||||
|
val groupCode = pb[1, 3, 2, 1].asULong
|
||||||
|
val applierUid = pb[1, 3, 2, 3].asUtf8String
|
||||||
|
val reason = pb[1, 3, 2, 5].asUtf8String
|
||||||
|
val applier = ContactHelper.getUinByUidAsync(applierUid).toLong()
|
||||||
|
LogCenter.log("入群申请($groupCode) $applier: \"$reason\"")
|
||||||
|
|
||||||
|
if(!GlobalEventTransmitter.GroupNoticeTransmitter
|
||||||
|
.transGroupApply(time, applier, reason, groupCode, NoticeSubType.Add)) {
|
||||||
|
LogCenter.log("入群申请推送失败!", Level.WARN)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
528 -> {
|
||||||
|
val groupCode = pb[1, 3, 2, 2, 3].asULong
|
||||||
|
val applierUid = pb[1, 3, 2, 2, 5].asUtf8String
|
||||||
|
val applier = ContactHelper.getUinByUidAsync(applierUid).toLong()
|
||||||
|
LogCenter.log("邀请入群申请($groupCode): $applier")
|
||||||
|
|
||||||
|
if(!GlobalEventTransmitter.GroupNoticeTransmitter
|
||||||
|
.transGroupApply(time, applier, "", groupCode, NoticeSubType.Invite)) {
|
||||||
|
LogCenter.log("邀请入群申请推送失败!", Level.WARN)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user