mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
Limit the number of members invited to join the group
This commit is contained in:
parent
d4e575f777
commit
58f4ebe411
@ -3,6 +3,7 @@ package group
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
@ -316,7 +317,12 @@ func InviteUserToGroup(c *gin.Context) {
|
||||
}
|
||||
req := &rpc.InviteUserToGroupReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
|
||||
if len(req.InvitedUserIDList) > constant.MaxNotificationNum {
|
||||
errMsg := req.OperationID + " too many, Limit: " + utils.IntToString(constant.MaxNotificationNum)
|
||||
log.NewError(req.OperationID, errMsg, len(req.InvitedUserIDList))
|
||||
c.JSON(http.StatusRequestEntityTooLarge, gin.H{"errCode": 400, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
|
@ -232,6 +232,9 @@ func GroupCreatedNotification(operationID, opUserID, groupID string, initMemberL
|
||||
continue
|
||||
}
|
||||
GroupCreatedTips.MemberList = append(GroupCreatedTips.MemberList, &groupMemberInfo)
|
||||
if len(GroupCreatedTips.MemberList) == constant.MaxNotificationNum {
|
||||
break
|
||||
}
|
||||
}
|
||||
groupNotification(constant.GroupCreatedNotification, &GroupCreatedTips, opUserID, groupID, "", operationID)
|
||||
}
|
||||
@ -536,7 +539,6 @@ func MemberInvitedNotification(operationID, groupID, opUserID, reason string, in
|
||||
}
|
||||
MemberInvitedTips.InvitedUserList = append(MemberInvitedTips.InvitedUserList, &groupMemberInfo)
|
||||
}
|
||||
|
||||
groupNotification(constant.MemberInvitedNotification, &MemberInvitedTips, opUserID, groupID, "", operationID)
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ type ApiUserInfo struct {
|
||||
|
||||
type GroupAddMemberInfo struct {
|
||||
UserID string `json:"userID" binding:"required"`
|
||||
RoleLevel int32 `json:"roleLevel" binding:"required"`
|
||||
RoleLevel int32 `json:"roleLevel" binding:"required,oneof= 1 3"`
|
||||
}
|
||||
|
||||
func SetErrCodeMsg(c *gin.Context, status int) *CommResp {
|
||||
|
@ -303,3 +303,5 @@ const BigVersion = "v2"
|
||||
const LogFileName = "OpenIM.log"
|
||||
|
||||
const StatisticsTimeInterval = 60
|
||||
|
||||
const MaxNotificationNum = 100
|
||||
|
Loading…
x
Reference in New Issue
Block a user