mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-15 14:35:57 +08:00
Limit the number of members invited to join the group
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user