feat: add agent channel

This commit is contained in:
tt
2025-06-10 10:17:18 +08:00
parent 312272b0e8
commit f00c00a57d
2 changed files with 12 additions and 2 deletions

View File

@@ -58,7 +58,9 @@ func (h *Handler) hasPermissionForChannel(channelId string, channelType uint8) (
return wkproto.ReasonSuccess, nil
}
// 客服频道,直接通过
if channelType == wkproto.ChannelTypeCustomerService || channelType == wkproto.ChannelTypeVisitors {
if channelType == wkproto.ChannelTypeCustomerService ||
channelType == wkproto.ChannelTypeVisitors ||
channelType == wkproto.ChannelTypeAgent {
return wkproto.ReasonSuccess, nil
}
@@ -116,6 +118,14 @@ func (h *Handler) hasPermissionForSender(channelId string, channelType uint8, e
}
}
// agent频道
if channelType == wkproto.ChannelTypeAgent {
uid, agentUID := options.GetUidAndAgentUIDWith(channelId)
if fromUid == uid || fromUid == agentUID {
return wkproto.ReasonSuccess, nil
}
}
// 系统发的消息直接通过
if options.G.IsSystemDevice(e.Conn.DeviceId) {
return wkproto.ReasonSuccess, nil

View File

@@ -29,7 +29,7 @@ func GetAgentChannelIDWith(uid, agentUID string) string {
}
// GetUidAndAgentUIDWith 获取用户ID和AgentID
func GetUidAndAgentUIDWith(channelId string) (string, string) {
func GetUidAndAgentUIDWith(channelId string) (uid string, agentUID string) {
channelIDs := strings.Split(channelId, "@")
if len(channelIDs) == 2 {
return channelIDs[0], channelIDs[1]