mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-08-07 19:50:07 +08:00
Refactor code
This commit is contained in:
parent
9409d6e05e
commit
4336a1a13e
@ -435,6 +435,11 @@ func (s *groupServer) GroupApplicationResponse(_ context.Context, req *pbGroup.G
|
||||
utils.CopyStructFields(&groupRequest, req)
|
||||
groupRequest.UserID = req.FromUserID
|
||||
groupRequest.HandleUserID = req.OpUserID
|
||||
|
||||
if !token_verify.IsMangerUserID(req.OpUserID) && !imdb.IsGroupOwnerAdmin(req.GroupID, req.OpUserID) {
|
||||
log.NewError(req.OperationID, "IsMangerUserID IsGroupOwnerAdmin false ", req.GroupID, req.OpUserID)
|
||||
return &pbGroup.GroupApplicationResponseResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
|
||||
}
|
||||
err := imdb.UpdateGroupRequest(groupRequest)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GroupApplicationResponse failed ", err.Error(), req.String())
|
||||
|
@ -112,7 +112,6 @@ type ApplicationGroupResponseReq struct {
|
||||
GroupID string `json:"groupID" binding:"required"`
|
||||
FromUserID string `json:"fromUserID" binding:"required"` //application from FromUserID
|
||||
HandledMsg string `json:"handledMsg"`
|
||||
//`json:"flag" binding:"required,oneof=-1 0 1"`
|
||||
HandleResult int32 `json:"handleResult" binding:"required,oneof=-1 1"`
|
||||
}
|
||||
type ApplicationGroupResponseResp struct {
|
||||
|
@ -210,6 +210,19 @@ func GetJoinedGroupIDListByUserID(userID string) ([]string, error) {
|
||||
return groupIDList, nil
|
||||
}
|
||||
|
||||
func IsGroupOwnerAdmin(groupID, UserID string) bool {
|
||||
groupMemberList, err := GetOwnerManagerByGroupID(groupID)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
for _, v := range groupMemberList {
|
||||
if v.UserID == UserID && v.RoleLevel > constant.GroupOrdinaryUsers {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
//
|
||||
//func SelectGroupList(groupID string) ([]string, error) {
|
||||
// var groupUserID string
|
||||
|
Loading…
x
Reference in New Issue
Block a user