mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
Merge branch 'errcode' of github.com:OpenIMSDK/Open-IM-Server into errcode
This commit is contained in:
commit
d0aa0a8772
@ -2,6 +2,7 @@ package push
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush"
|
||||
@ -101,6 +102,16 @@ func (p *Pusher) Push2User(ctx context.Context, userIDs []string, msg *sdkws.Msg
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Pusher) UnmarshalNotificationElem(bytes []byte, t interface{}) error {
|
||||
var notificationElem struct {
|
||||
Detail string `json:"detail,omitempty"`
|
||||
}
|
||||
if err := json.Unmarshal(bytes, ¬ificationElem); err != nil {
|
||||
return err
|
||||
}
|
||||
return json.Unmarshal([]byte(notificationElem.Detail), t)
|
||||
}
|
||||
|
||||
func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws.MsgData) (err error) {
|
||||
operationID := mcontext.GetOperationID(ctx)
|
||||
log.Debug(operationID, "Get super group msg from msg_transfer And push msg", msg.String(), groupID)
|
||||
@ -113,6 +124,21 @@ func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
switch msg.ContentType {
|
||||
case constant.MemberQuitNotification:
|
||||
var tips sdkws.MemberQuitTips
|
||||
if p.UnmarshalNotificationElem(msg.Content, &tips) != nil {
|
||||
return err
|
||||
}
|
||||
pushToUserIDs = append(pushToUserIDs, tips.QuitUser.UserID)
|
||||
case constant.MemberKickedNotification:
|
||||
var tips sdkws.MemberKickedTips
|
||||
if p.UnmarshalNotificationElem(msg.Content, &tips) != nil {
|
||||
return err
|
||||
}
|
||||
kickedUsers := utils.Slice(tips.KickedUserList, func(e *sdkws.GroupMemberFullInfo) string { return e.UserID })
|
||||
pushToUserIDs = append(pushToUserIDs, kickedUsers...)
|
||||
}
|
||||
}
|
||||
wsResults, err := p.GetConnsAndOnlinePush(ctx, msg, pushToUserIDs)
|
||||
if err != nil {
|
||||
|
@ -723,6 +723,7 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup
|
||||
}
|
||||
|
||||
func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq) (resp *pbGroup.JoinGroupResp, err error) {
|
||||
defer log.ZInfo(ctx, "JoinGroup.Return")
|
||||
user, err := s.User.GetUserInfo(ctx, req.InviterUserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -740,6 +741,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
|
||||
} else if !s.IsNotFound(err) && utils.Unwrap(err) != errs.ErrRecordNotFound {
|
||||
return nil, err
|
||||
}
|
||||
log.ZInfo(ctx, "JoinGroup.groupInfo", "group", group, "eq", group.NeedVerification == constant.Directly)
|
||||
resp = &pbGroup.JoinGroupResp{}
|
||||
if group.NeedVerification == constant.Directly {
|
||||
if group.GroupType == constant.SuperGroup {
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user