mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-24 02:16:16 +08:00
Merge branch 'errcode' of github.com:OpenIMSDK/Open-IM-Server into errcode
This commit is contained in:
commit
da3f9670e9
@ -40,12 +40,12 @@ func (u *UserMap) Get(key string, platformID int) ([]*Client, bool, bool) {
|
|||||||
func (u *UserMap) Set(key string, v *Client) {
|
func (u *UserMap) Set(key string, v *Client) {
|
||||||
allClients, existed := u.m.Load(key)
|
allClients, existed := u.m.Load(key)
|
||||||
if existed {
|
if existed {
|
||||||
log.ZDebug(context.Background(), "Set existed", "user_id", key, "client", v)
|
log.ZDebug(context.Background(), "Set existed", "user_id", key, "client", *v)
|
||||||
oldClients := allClients.([]*Client)
|
oldClients := allClients.([]*Client)
|
||||||
oldClients = append(oldClients, v)
|
oldClients = append(oldClients, v)
|
||||||
u.m.Store(key, oldClients)
|
u.m.Store(key, oldClients)
|
||||||
} else {
|
} else {
|
||||||
log.ZDebug(context.Background(), "Set not existed", "user_id", key, "client", v)
|
log.ZDebug(context.Background(), "Set not existed", "user_id", key, "client", *v)
|
||||||
var clients []*Client
|
var clients []*Client
|
||||||
clients = append(clients, v)
|
clients = append(clients, v)
|
||||||
u.m.Store(key, clients)
|
u.m.Store(key, clients)
|
||||||
|
@ -724,7 +724,7 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if groupRequest.HandleResult != 0 {
|
if groupRequest.HandleResult != 0 {
|
||||||
return nil, errs.ErrArgs.Wrap("group request already processed")
|
return nil, errs.ErrGroupRequestHandled.Wrap("group request already processed")
|
||||||
}
|
}
|
||||||
var inGroup bool
|
var inGroup bool
|
||||||
_, err = s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, req.FromUserID)
|
_, err = s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, req.FromUserID)
|
||||||
@ -733,17 +733,16 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup
|
|||||||
} else if !s.IsNotFound(err) {
|
} else if !s.IsNotFound(err) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
user, err := s.User.GetPublicUserInfo(ctx, req.FromUserID)
|
if _, err := s.User.GetPublicUserInfo(ctx, req.FromUserID); err != nil {
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var member *relationTb.GroupMemberModel
|
var member *relationTb.GroupMemberModel
|
||||||
if (!inGroup) && req.HandleResult == constant.GroupResponseAgree {
|
if (!inGroup) && req.HandleResult == constant.GroupResponseAgree {
|
||||||
member = &relationTb.GroupMemberModel{
|
member = &relationTb.GroupMemberModel{
|
||||||
GroupID: req.GroupID,
|
GroupID: req.GroupID,
|
||||||
UserID: user.UserID,
|
UserID: req.FromUserID,
|
||||||
Nickname: user.Nickname,
|
Nickname: "",
|
||||||
FaceURL: user.FaceURL,
|
FaceURL: "",
|
||||||
RoleLevel: constant.GroupOrdinaryUsers,
|
RoleLevel: constant.GroupOrdinaryUsers,
|
||||||
JoinTime: time.Now(),
|
JoinTime: time.Now(),
|
||||||
JoinSource: groupRequest.JoinSource,
|
JoinSource: groupRequest.JoinSource,
|
||||||
@ -762,29 +761,12 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup
|
|||||||
switch req.HandleResult {
|
switch req.HandleResult {
|
||||||
case constant.GroupResponseAgree:
|
case constant.GroupResponseAgree:
|
||||||
s.Notification.GroupApplicationAcceptedNotification(ctx, req)
|
s.Notification.GroupApplicationAcceptedNotification(ctx, req)
|
||||||
if !inGroup {
|
|
||||||
groupMember := &relationTb.GroupMemberModel{}
|
|
||||||
groupMember.GroupID = group.GroupID
|
|
||||||
groupMember.RoleLevel = constant.GroupOrdinaryUsers
|
|
||||||
groupMember.OperatorUserID = mcontext.GetOpUserID(ctx)
|
|
||||||
groupMember.JoinSource = groupRequest.JoinSource
|
|
||||||
groupMember.InviterUserID = groupRequest.InviterUserID
|
|
||||||
groupMember.JoinTime = time.Now()
|
|
||||||
groupMember.MuteEndTime = time.Unix(0, 0)
|
|
||||||
if err := CallbackBeforeMemberJoinGroup(ctx, groupMember, group.Ex); err != nil && err != errs.ErrCallbackContinue {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if err := s.GroupDatabase.CreateGroup(ctx, nil, []*relationTb.GroupMemberModel{groupMember}); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if err := s.conversationRpcClient.GroupChatFirstCreateConversation(ctx, req.GroupID, []string{req.FromUserID}); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
s.Notification.MemberEnterNotification(ctx, req)
|
|
||||||
}
|
|
||||||
case constant.GroupResponseRefuse:
|
case constant.GroupResponseRefuse:
|
||||||
s.Notification.GroupApplicationRejectedNotification(ctx, req)
|
s.Notification.GroupApplicationRejectedNotification(ctx, req)
|
||||||
}
|
}
|
||||||
|
if member != nil {
|
||||||
|
s.Notification.MemberEnterNotification(ctx, req)
|
||||||
|
}
|
||||||
return &pbGroup.GroupApplicationResponseResp{}, nil
|
return &pbGroup.GroupApplicationResponseResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ const (
|
|||||||
OwnerNotAllowedQuitError = 1207 //群主不能退群
|
OwnerNotAllowedQuitError = 1207 //群主不能退群
|
||||||
GroupTypeNotSupport = 1208
|
GroupTypeNotSupport = 1208
|
||||||
GroupNoOwner = 1209
|
GroupNoOwner = 1209
|
||||||
|
GroupRequestHandled = 1210
|
||||||
|
|
||||||
// 关系链错误码
|
// 关系链错误码
|
||||||
CanNotAddYourselfError = 1301 //不能添加自己为好友
|
CanNotAddYourselfError = 1301 //不能添加自己为好友
|
||||||
|
@ -62,4 +62,5 @@ var (
|
|||||||
|
|
||||||
ErrFileUploadedComplete = NewCodeError(FileUploadedCompleteError, "FileUploadedComplete")
|
ErrFileUploadedComplete = NewCodeError(FileUploadedCompleteError, "FileUploadedComplete")
|
||||||
ErrFileUploadedExpired = NewCodeError(FileUploadedExpiredError, "FileUploadedExpiredError")
|
ErrFileUploadedExpired = NewCodeError(FileUploadedExpiredError, "FileUploadedExpiredError")
|
||||||
|
ErrGroupRequestHandled = NewCodeError(GroupRequestHandled, "GroupRequestHandled")
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user