mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-09 19:45:58 +08:00
fate: api, rpc QuitGroup req add userID (#1244)
* feat: v2 to v3 data conversion * feat: v2 to v3 data conversion * fix: CallbackBeforeCreateGroup * fix: NotificationUserInfoUpdate * fix: NotificationUserInfoUpdate * chore: update pkg github.com/OpenIMSDK/protocol v0.0.26 * chore: code format * update pkg * feat: QuitGroup support administrator operations * feat: QuitGroup support administrator operations * fix: checkMongo uri * fix: k8s minio prefix * fix: k8s minio prefix * fix: k8s minio prefix * fix: k8s minio prefix test * fix: k8s minio prefix test
This commit is contained in:
@@ -852,32 +852,40 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbgroup.JoinGroupReq)
|
||||
|
||||
func (s *groupServer) QuitGroup(ctx context.Context, req *pbgroup.QuitGroupReq) (*pbgroup.QuitGroupResp, error) {
|
||||
resp := &pbgroup.QuitGroupResp{}
|
||||
if req.UserID == "" {
|
||||
req.UserID = mcontext.GetOpUserID(ctx)
|
||||
} else {
|
||||
if err := authverify.CheckAccessV3(ctx, req.UserID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if group.GroupType == constant.SuperGroup {
|
||||
if err := s.GroupDatabase.DeleteSuperGroupMember(ctx, req.GroupID, []string{mcontext.GetOpUserID(ctx)}); err != nil {
|
||||
if err := s.GroupDatabase.DeleteSuperGroupMember(ctx, req.GroupID, []string{req.UserID}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.Notification.SuperGroupNotification(ctx, mcontext.GetOpUserID(ctx), mcontext.GetOpUserID(ctx))
|
||||
_ = s.Notification.SuperGroupNotification(ctx, req.UserID, req.UserID)
|
||||
} else {
|
||||
info, err := s.TakeGroupMember(ctx, req.GroupID, mcontext.GetOpUserID(ctx))
|
||||
info, err := s.TakeGroupMember(ctx, req.GroupID, req.UserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if info.RoleLevel == constant.GroupOwner {
|
||||
return nil, errs.ErrNoPermission.Wrap("group owner can't quit")
|
||||
}
|
||||
err = s.GroupDatabase.DeleteGroupMember(ctx, req.GroupID, []string{mcontext.GetOpUserID(ctx)})
|
||||
err = s.GroupDatabase.DeleteGroupMember(ctx, req.GroupID, []string{req.UserID})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.Notification.MemberQuitNotification(ctx, s.groupMemberDB2PB(info, 0))
|
||||
_ = s.Notification.MemberQuitNotification(ctx, s.groupMemberDB2PB(info, 0))
|
||||
}
|
||||
if err := s.deleteMemberAndSetConversationSeq(ctx, req.GroupID, []string{mcontext.GetOpUserID(ctx)}); err != nil {
|
||||
if err := s.deleteMemberAndSetConversationSeq(ctx, req.GroupID, []string{req.UserID}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user