Skip to content

Commit 0e5d0d6

Browse files
committed
fix: sn_ not sort
1 parent 627e2be commit 0e5d0d6

File tree

2 files changed

+4
-396
lines changed

2 files changed

+4
-396
lines changed

pkg/msgprocessor/conversation.go

Lines changed: 4 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,6 @@ func GetChatConversationIDByMsg(msg *sdkws.MsgData) string {
6565
return ""
6666
}
6767

68-
func GenConversationUniqueKey(msg *sdkws.MsgData) string {
69-
switch msg.SessionType {
70-
case constant.SingleChatType, constant.NotificationChatType:
71-
l := []string{msg.SendID, msg.RecvID}
72-
sort.Strings(l)
73-
return strings.Join(l, "_")
74-
case constant.ReadGroupChatType:
75-
return msg.GroupID
76-
}
77-
return ""
78-
}
79-
8068
func GetConversationIDByMsg(msg *sdkws.MsgData) string {
8169
options := Options(msg.Options)
8270
switch msg.SessionType {
@@ -98,10 +86,12 @@ func GetConversationIDByMsg(msg *sdkws.MsgData) string {
9886
}
9987
return "sg_" + msg.GroupID // super group chat
10088
case constant.NotificationChatType:
89+
l := []string{msg.SendID, msg.RecvID}
90+
sort.Strings(l)
10191
if !options.IsNotNotification() {
102-
return "n_" + msg.SendID + "_" + msg.RecvID // super group chat
92+
return "n_" + strings.Join(l, "_")
10393
}
104-
return "sn_" + msg.SendID + "_" + msg.RecvID // server notification chat
94+
return "sn_" + strings.Join(l, "_")
10595
}
10696
return ""
10797
}
@@ -124,30 +114,6 @@ func GetConversationIDBySessionType(sessionType int, ids ...string) string {
124114
return ""
125115
}
126116

127-
func GetNotificationConversationIDByConversationID(conversationID string) string {
128-
l := strings.Split(conversationID, "_")
129-
if len(l) > 1 {
130-
l[0] = "n"
131-
return strings.Join(l, "_")
132-
}
133-
134-
return ""
135-
}
136-
137-
func GetNotificationConversationID(sessionType int, ids ...string) string {
138-
sort.Strings(ids)
139-
if len(ids) > 2 || len(ids) < 1 {
140-
return ""
141-
}
142-
switch sessionType {
143-
case constant.SingleChatType:
144-
return "n_" + strings.Join(ids, "_") // single chat
145-
case constant.ReadGroupChatType:
146-
return "n_" + ids[0] // super group chat
147-
}
148-
return ""
149-
}
150-
151117
func IsNotification(conversationID string) bool {
152118
return strings.HasPrefix(conversationID, "n_")
153119
}
@@ -156,30 +122,6 @@ func IsNotificationByMsg(msg *sdkws.MsgData) bool {
156122
return !Options(msg.Options).IsNotNotification()
157123
}
158124

159-
func ParseConversationID(msg *sdkws.MsgData) (isNotification bool, conversationID string) {
160-
options := Options(msg.Options)
161-
switch msg.SessionType {
162-
case constant.SingleChatType:
163-
l := []string{msg.SendID, msg.RecvID}
164-
sort.Strings(l)
165-
if !options.IsNotNotification() {
166-
return true, "n_" + strings.Join(l, "_")
167-
}
168-
return false, "si_" + strings.Join(l, "_") // single chat
169-
case constant.ReadGroupChatType:
170-
if !options.IsNotNotification() {
171-
return true, "n_" + msg.GroupID // super group chat
172-
}
173-
return false, "sg_" + msg.GroupID // super group chat
174-
case constant.NotificationChatType:
175-
if !options.IsNotNotification() {
176-
return true, "n_" + msg.SendID + "_" + msg.RecvID // super group chat
177-
}
178-
return false, "sn_" + msg.SendID + "_" + msg.RecvID // server notification chat
179-
}
180-
return false, ""
181-
}
182-
183125
type MsgBySeq []*sdkws.MsgData
184126

185127
func (s MsgBySeq) Len() int {

0 commit comments

Comments
 (0)