fix: sn not sort (#2682)

* fix: GroupApplicationAcceptedNotification

* fix: GroupApplicationAcceptedNotification

* fix: NotificationUserInfoUpdate

* cicd: robot automated Change

* fix: component

* fix: getConversationInfo

* feat: cron task

* feat: cron task

* feat: cron task

* feat: cron task

* feat: cron task

* fix: minio config url recognition error

* update gomake version

* update gomake version

* fix: seq conversion bug

* fix: redis pipe exec

* fix: ImportFriends

* fix: A large number of logs keysAndValues ​​length is not even

* feat: mark read aggregate write

* feat: online status supports redis cluster

* feat: online status supports redis cluster

* feat: online status supports redis cluster

* merge

* merge

* read seq is written to mongo

* read seq is written to mongo

* fix: invitation to join group notification

* fix: friend op_user_id

* feat: optimizing asynchronous context

* feat: optimizing memamq size

* feat: add GetSeqMessage

* feat: GroupApplicationAgreeMemberEnterNotification

* feat: GroupApplicationAgreeMemberEnterNotification

* feat: go.mod

* feat: go.mod

* feat: join group notification and get seq

* feat: join group notification and get seq

* feat: avoid pulling messages from sessions with a large number of max seq values of 0

* feat: API supports gzip

* go.mod

* fix: nil pointer error on close

* fix: listen error

* fix: listen error

* update go.mod

* feat: add log

* fix: token parse token value

* fix: GetMsgBySeqs boundary issues

* fix: sn_ not sort

* fix: sn_ not sort

* fix: sn_ not sort

---------

Co-authored-by: withchao <withchao@users.noreply.github.com>
pull/2686/head v3.8.1-rc.4
chao 2 months ago committed by GitHub
parent 0892c1c0c3
commit 765fa17e7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -39,7 +39,9 @@ func GetNotificationConversationIDByMsg(msg *sdkws.MsgData) string {
case constant.ReadGroupChatType:
return "n_" + msg.GroupID
case constant.NotificationChatType:
return "n_" + msg.SendID + "_" + msg.RecvID
l := []string{msg.SendID, msg.RecvID}
sort.Strings(l)
return "n_" + strings.Join(l, "_")
}
return ""
}
@ -55,21 +57,11 @@ func GetChatConversationIDByMsg(msg *sdkws.MsgData) string {
case constant.ReadGroupChatType:
return "sg_" + msg.GroupID
case constant.NotificationChatType:
return "sn_" + msg.SendID + "_" + msg.RecvID
}
return ""
}
func GenConversationUniqueKey(msg *sdkws.MsgData) string {
switch msg.SessionType {
case constant.SingleChatType, constant.NotificationChatType:
l := []string{msg.SendID, msg.RecvID}
sort.Strings(l)
return strings.Join(l, "_")
case constant.ReadGroupChatType:
return msg.GroupID
return "sn_" + strings.Join(l, "_")
}
return ""
}
@ -94,10 +86,12 @@ func GetConversationIDByMsg(msg *sdkws.MsgData) string {
}
return "sg_" + msg.GroupID // super group chat
case constant.NotificationChatType:
l := []string{msg.SendID, msg.RecvID}
sort.Strings(l)
if !options.IsNotNotification() {
return "n_" + msg.SendID + "_" + msg.RecvID // super group chat
return "n_" + strings.Join(l, "_")
}
return "sn_" + msg.SendID + "_" + msg.RecvID // server notification chat
return "sn_" + strings.Join(l, "_")
}
return ""
}
@ -120,30 +114,6 @@ func GetConversationIDBySessionType(sessionType int, ids ...string) string {
return ""
}
func GetNotificationConversationIDByConversationID(conversationID string) string {
l := strings.Split(conversationID, "_")
if len(l) > 1 {
l[0] = "n"
return strings.Join(l, "_")
}
return ""
}
func GetNotificationConversationID(sessionType int, ids ...string) string {
sort.Strings(ids)
if len(ids) > 2 || len(ids) < 1 {
return ""
}
switch sessionType {
case constant.SingleChatType:
return "n_" + strings.Join(ids, "_") // single chat
case constant.ReadGroupChatType:
return "n_" + ids[0] // super group chat
}
return ""
}
func IsNotification(conversationID string) bool {
return strings.HasPrefix(conversationID, "n_")
}
@ -152,30 +122,6 @@ func IsNotificationByMsg(msg *sdkws.MsgData) bool {
return !Options(msg.Options).IsNotNotification()
}
func ParseConversationID(msg *sdkws.MsgData) (isNotification bool, conversationID string) {
options := Options(msg.Options)
switch msg.SessionType {
case constant.SingleChatType:
l := []string{msg.SendID, msg.RecvID}
sort.Strings(l)
if !options.IsNotNotification() {
return true, "n_" + strings.Join(l, "_")
}
return false, "si_" + strings.Join(l, "_") // single chat
case constant.ReadGroupChatType:
if !options.IsNotNotification() {
return true, "n_" + msg.GroupID // super group chat
}
return false, "sg_" + msg.GroupID // super group chat
case constant.NotificationChatType:
if !options.IsNotNotification() {
return true, "n_" + msg.SendID + "_" + msg.RecvID // super group chat
}
return false, "sn_" + msg.SendID + "_" + msg.RecvID // server notification chat
}
return false, ""
}
type MsgBySeq []*sdkws.MsgData
func (s MsgBySeq) Len() int {

@ -1,334 +0,0 @@
// Copyright © 2023 OpenIM. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package msgprocessor
import (
"testing"
"github.com/openimsdk/protocol/sdkws"
"google.golang.org/protobuf/proto"
)
func TestGetNotificationConversationIDByMsg(t *testing.T) {
type args struct {
msg *sdkws.MsgData
}
tests := []struct {
name string
args args
want string
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := GetNotificationConversationIDByMsg(tt.args.msg); got != tt.want {
t.Errorf("GetNotificationConversationIDByMsg() = %v, want %v", got, tt.want)
}
})
}
}
func TestGetChatConversationIDByMsg(t *testing.T) {
type args struct {
msg *sdkws.MsgData
}
tests := []struct {
name string
args args
want string
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := GetChatConversationIDByMsg(tt.args.msg); got != tt.want {
t.Errorf("GetChatConversationIDByMsg() = %v, want %v", got, tt.want)
}
})
}
}
func TestGenConversationUniqueKey(t *testing.T) {
type args struct {
msg *sdkws.MsgData
}
tests := []struct {
name string
args args
want string
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := GenConversationUniqueKey(tt.args.msg); got != tt.want {
t.Errorf("GenConversationUniqueKey() = %v, want %v", got, tt.want)
}
})
}
}
func TestGetConversationIDByMsg(t *testing.T) {
type args struct {
msg *sdkws.MsgData
}
tests := []struct {
name string
args args
want string
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := GetConversationIDByMsg(tt.args.msg); got != tt.want {
t.Errorf("GetConversationIDByMsg() = %v, want %v", got, tt.want)
}
})
}
}
func TestGetConversationIDBySessionType(t *testing.T) {
type args struct {
sessionType int
ids []string
}
tests := []struct {
name string
args args
want string
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := GetConversationIDBySessionType(tt.args.sessionType, tt.args.ids...); got != tt.want {
t.Errorf("GetConversationIDBySessionType() = %v, want %v", got, tt.want)
}
})
}
}
func TestGetNotificationConversationIDByConversationID(t *testing.T) {
type args struct {
conversationID string
}
tests := []struct {
name string
args args
want string
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := GetNotificationConversationIDByConversationID(tt.args.conversationID); got != tt.want {
t.Errorf("GetNotificationConversationIDByConversationID() = %v, want %v", got, tt.want)
}
})
}
}
func TestGetNotificationConversationID(t *testing.T) {
type args struct {
sessionType int
ids []string
}
tests := []struct {
name string
args args
want string
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := GetNotificationConversationID(tt.args.sessionType, tt.args.ids...); got != tt.want {
t.Errorf("GetNotificationConversationID() = %v, want %v", got, tt.want)
}
})
}
}
func TestIsNotification(t *testing.T) {
type args struct {
conversationID string
}
tests := []struct {
name string
args args
want bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := IsNotification(tt.args.conversationID); got != tt.want {
t.Errorf("IsNotification() = %v, want %v", got, tt.want)
}
})
}
}
func TestIsNotificationByMsg(t *testing.T) {
type args struct {
msg *sdkws.MsgData
}
tests := []struct {
name string
args args
want bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := IsNotificationByMsg(tt.args.msg); got != tt.want {
t.Errorf("IsNotificationByMsg() = %v, want %v", got, tt.want)
}
})
}
}
func TestParseConversationID(t *testing.T) {
type args struct {
msg *sdkws.MsgData
}
tests := []struct {
name string
args args
wantIsNotification bool
wantConversationID string
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotIsNotification, gotConversationID := ParseConversationID(tt.args.msg)
if gotIsNotification != tt.wantIsNotification {
t.Errorf("ParseConversationID() gotIsNotification = %v, want %v", gotIsNotification, tt.wantIsNotification)
}
if gotConversationID != tt.wantConversationID {
t.Errorf("ParseConversationID() gotConversationID = %v, want %v", gotConversationID, tt.wantConversationID)
}
})
}
}
func TestMsgBySeq_Len(t *testing.T) {
tests := []struct {
name string
s MsgBySeq
want int
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.s.Len(); got != tt.want {
t.Errorf("MsgBySeq.Len() = %v, want %v", got, tt.want)
}
})
}
}
func TestMsgBySeq_Less(t *testing.T) {
type args struct {
i int
j int
}
tests := []struct {
name string
s MsgBySeq
args args
want bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.s.Less(tt.args.i, tt.args.j); got != tt.want {
t.Errorf("MsgBySeq.Less() = %v, want %v", got, tt.want)
}
})
}
}
func TestMsgBySeq_Swap(t *testing.T) {
type args struct {
i int
j int
}
tests := []struct {
name string
s MsgBySeq
args args
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tt.s.Swap(tt.args.i, tt.args.j)
})
}
}
func TestPb2String(t *testing.T) {
type args struct {
pb proto.Message
}
tests := []struct {
name string
args args
want string
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := Pb2String(tt.args.pb)
if (err != nil) != tt.wantErr {
t.Errorf("Pb2String() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("Pb2String() = %v, want %v", got, tt.want)
}
})
}
}
func TestString2Pb(t *testing.T) {
type args struct {
s string
pb proto.Message
}
tests := []struct {
name string
args args
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := String2Pb(tt.args.s, tt.args.pb); (err != nil) != tt.wantErr {
t.Errorf("String2Pb() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
Loading…
Cancel
Save