Merge branch 'errcode' of github.com:OpenIMSDK/Open-IM-Server into errcode

This commit is contained in:
wangchuxiao
2023-05-19 16:12:06 +08:00
5 changed files with 55 additions and 14 deletions
+2 -2
View File
@@ -14,7 +14,7 @@ func UsersDB2Pb(users []*relationTb.UserModel) (result []*sdkws.UserInfo) {
userPb.Nickname = user.Nickname
userPb.FaceURL = user.FaceURL
userPb.Ex = user.Ex
userPb.CreateTime = user.CreateTime.Unix()
userPb.CreateTime = user.CreateTime.UnixMilli()
userPb.AppMangerLevel = user.AppMangerLevel
userPb.GlobalRecvMsgOpt = user.GlobalRecvMsgOpt
result = append(result, &userPb)
@@ -28,7 +28,7 @@ func UserPb2DB(user *sdkws.UserInfo) *relationTb.UserModel {
userDB.Nickname = user.Nickname
userDB.FaceURL = user.FaceURL
userDB.Ex = user.Ex
userDB.CreateTime = time.Unix(user.CreateTime, 0)
userDB.CreateTime = time.UnixMilli(user.CreateTime)
userDB.AppMangerLevel = user.AppMangerLevel
userDB.GlobalRecvMsgOpt = user.GlobalRecvMsgOpt
return &userDB
+5 -3
View File
@@ -222,9 +222,11 @@ func (c *ConversationDataBase) CreateGroupChatConversation(ctx context.Context,
conversations = append(conversations, &conversation)
}
cache = cache.DelConversationIDs(notExistUserIDs...).DelUserConversationIDsHash(notExistUserIDs...)
err = c.conversationDB.Create(ctx, conversations)
if err != nil {
return err
if len(conversations) > 0 {
err = c.conversationDB.Create(ctx, conversations)
if err != nil {
return err
}
}
_, err = c.conversationDB.UpdateByMap(ctx, existConversationUserIDs, conversationID, map[string]interface{}{"max_seq": 0})
if err != nil {
+20 -9
View File
@@ -87,7 +87,8 @@ func (g *GroupNotificationSender) getGroupInfo(ctx context.Context, groupID stri
}
func (g *GroupNotificationSender) getGroupMembers(ctx context.Context, groupID string, userIDs []string) ([]*sdkws.GroupMemberFullInfo, error) {
members, err := g.db.FindGroupMember(ctx, []string{groupID}, userIDs, []int32{constant.GroupOwner})
//members, err := g.db.FindGroupMember(ctx, []string{groupID}, userIDs, []int32{constant.GroupOwner})
members, err := g.db.FindGroupMember(ctx, []string{groupID}, userIDs, nil)
if err != nil {
return nil, err
}
@@ -351,9 +352,9 @@ func (g *GroupNotificationSender) JoinGroupApplicationNotification(ctx context.C
if err != nil {
return err
}
userIDs = append(userIDs, req.InviterUserID, mcontext.GetOpUserID(ctx))
tips := &sdkws.JoinGroupApplicationTips{Group: group, Applicant: user, ReqMsg: req.ReqMessage}
for _, userID := range userIDs {
log.ZInfo(ctx, "JoinGroupApplicationNotification", "group", req.GroupID, "userID", userID)
for _, userID := range utils.Distinct(userIDs) {
err = g.msgClient.Notification(ctx, mcontext.GetOpUserID(ctx), userID, constant.JoinGroupApplicationNotification, tips)
if err != nil {
log.ZError(ctx, "JoinGroupApplicationNotification failed", err, "group", req.GroupID, "userID", userID)
@@ -613,11 +614,16 @@ func (g *GroupNotificationSender) GroupMutedNotification(ctx context.Context, gr
if err != nil {
return err
}
user, err := g.getGroupMember(ctx, groupID, mcontext.GetOpUserID(ctx))
users, err := g.getGroupMembers(ctx, groupID, []string{mcontext.GetOpUserID(ctx)})
if err != nil {
return err
}
tips := &sdkws.GroupMutedTips{Group: group, OpUser: user}
tips := &sdkws.GroupMutedTips{Group: group}
if len(users) > 0 {
tips.OpUser = users[0]
} else {
tips.OpUser = &sdkws.GroupMemberFullInfo{UserID: mcontext.GetOpUserID(ctx), GroupID: groupID}
}
return g.msgClient.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMutedNotification, tips)
}
@@ -632,12 +638,17 @@ func (g *GroupNotificationSender) GroupCancelMutedNotification(ctx context.Conte
if err != nil {
return err
}
user, err := g.getGroupMember(ctx, groupID, mcontext.GetOpUserID(ctx))
users, err := g.getGroupMembers(ctx, groupID, []string{mcontext.GetOpUserID(ctx)})
if err != nil {
return err
}
tips := &sdkws.GroupCancelMutedTips{Group: group, OpUser: user}
return g.msgClient.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMutedNotification, tips)
tips := &sdkws.GroupCancelMutedTips{Group: group}
if len(users) > 0 {
tips.OpUser = users[0]
} else {
tips.OpUser = &sdkws.GroupMemberFullInfo{UserID: mcontext.GetOpUserID(ctx), GroupID: groupID}
}
return g.msgClient.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupCancelMutedNotification, tips)
}
func (g *GroupNotificationSender) GroupMemberInfoSetNotification(ctx context.Context, groupID, groupMemberUserID string) (err error) {
@@ -694,7 +705,7 @@ func (g *GroupNotificationSender) MemberEnterDirectlyNotification(ctx context.Co
return err
}
tips := &sdkws.MemberEnterTips{Group: group, EntrantUser: user}
return g.msgClient.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberCancelMutedNotification, tips)
return g.msgClient.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.MemberEnterNotification, tips)
}
func (g *GroupNotificationSender) SuperGroupNotification(ctx context.Context, sendID, recvID string) (err error) {