This commit is contained in:
wangchuxiao 2023-05-06 11:31:04 +08:00
parent a62335a910
commit d369d05ee4

View File

@ -171,16 +171,29 @@ func GetHashCode(s string) uint32 {
} }
func GetConversationIDByMsg(msg *sdkws.MsgData) string { func GetConversationIDByMsg(msg *sdkws.MsgData) string {
options := Options(msg.Options)
switch msg.SessionType { switch msg.SessionType {
case constant.SingleChatType: case constant.SingleChatType:
l := []string{msg.SendID, msg.RecvID} l := []string{msg.SendID, msg.RecvID}
sort.Strings(l) sort.Strings(l)
if options.IsNotification() {
return "n_" + strings.Join(l, "_")
}
return "si_" + strings.Join(l, "_") // single chat return "si_" + strings.Join(l, "_") // single chat
case constant.GroupChatType: case constant.GroupChatType:
if options.IsNotification() {
return "n_" + msg.GroupID // group chat
}
return "g_" + msg.GroupID // group chat return "g_" + msg.GroupID // group chat
case constant.SuperGroupChatType: case constant.SuperGroupChatType:
if options.IsNotification() {
return "n_" + msg.GroupID // super group chat
}
return "sg_" + msg.GroupID // super group chat return "sg_" + msg.GroupID // super group chat
case constant.NotificationChatType: case constant.NotificationChatType:
if options.IsNotification() {
return "n_" + msg.SendID + "_" + msg.RecvID // super group chat
}
return "sn_" + msg.SendID + "_" + msg.RecvID // server notification chat return "sn_" + msg.SendID + "_" + msg.RecvID // server notification chat
} }
return "" return ""