diff --git a/cmd/open_im_api/main.go b/cmd/open_im_api/main.go index 1e3e0e1df..4edf037c4 100644 --- a/cmd/open_im_api/main.go +++ b/cmd/open_im_api/main.go @@ -54,7 +54,7 @@ func main() { { userRouterGroup.POST("/update_user_info", user.UpdateUserInfo) //1 userRouterGroup.POST("/set_global_msg_recv_opt", user.SetGlobalRecvMessageOpt) - userRouterGroup.POST("/get_users_info", user.GetUsersInfo) //1 + userRouterGroup.POST("/get_users_info", user.GetUsersPublicInfo) //1 userRouterGroup.POST("/get_self_user_info", user.GetSelfUserInfo) //1 userRouterGroup.POST("/get_users_online_status", user.GetUsersOnlineStatus) //1 userRouterGroup.POST("/get_users_info_from_cache", user.GetUsersInfoFromCache) @@ -95,9 +95,9 @@ func main() { groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner) //1 groupRouterGroup.POST("/get_recv_group_applicationList", group.GetRecvGroupApplicationList) //1 groupRouterGroup.POST("/get_user_req_group_applicationList", group.GetUserReqGroupApplicationList) - groupRouterGroup.POST("/get_groups_info", group.GetGroupsInfo) //1 - groupRouterGroup.POST("/kick_group", group.KickGroupMember) //1 - groupRouterGroup.POST("/get_group_member_list", group.GetGroupMemberList) //no use + groupRouterGroup.POST("/get_groups_info", group.GetGroupsInfo) //1 + groupRouterGroup.POST("/kick_group", group.KickGroupMember) //1 + // groupRouterGroup.POST("/get_group_member_list", group.GetGroupMemberList) //no use groupRouterGroup.POST("/get_group_all_member_list", group.GetGroupAllMemberList) //1 groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //1 groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup) //1 diff --git a/docker-compose.yaml b/docker-compose.yaml index 5b2c15712..81697ebb6 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -115,7 +115,7 @@ services: open_im_server: - image: openim/open_im_server:v2.3.1 + image: openim/open_im_server:v2.3.2 container_name: open_im_server volumes: - ./logs:/Open-IM-Server/logs diff --git a/internal/api/group/group.go b/internal/api/group/group.go index ac8364d98..5c4427875 100644 --- a/internal/api/group/group.go +++ b/internal/api/group/group.go @@ -320,12 +320,7 @@ 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) @@ -385,7 +380,13 @@ func CreateGroup(c *gin.Context) { c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) return } - // + + if len(params.MemberList) > constant.MaxNotificationNum { + errMsg := params.OperationID + " too many members " + utils.Int32ToString(int32(len(params.MemberList))) + log.Error(params.OperationID, errMsg) + c.JSON(http.StatusOK, gin.H{"errCode": 400, "errMsg": errMsg}) + return + } req := &rpc.CreateGroupReq{GroupInfo: &open_im_sdk.GroupInfo{}} utils.CopyStructFields(req.GroupInfo, ¶ms) diff --git a/internal/api/user/user.go b/internal/api/user/user.go index 6876bda04..dff63db97 100644 --- a/internal/api/user/user.go +++ b/internal/api/user/user.go @@ -160,7 +160,7 @@ func GetBlackIDListFromCache(c *gin.Context) { // @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误" // @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等" // @Router /user/get_users_info [post] -func GetUsersInfo(c *gin.Context) { +func GetUsersPublicInfo(c *gin.Context) { params := api.GetUsersInfoReq{} if err := c.BindJSON(¶ms); err != nil { log.NewError("0", "BindJSON failed ", err.Error()) diff --git a/internal/msg_transfer/logic/init.go b/internal/msg_transfer/logic/init.go index e5ad296ff..0a80d155c 100644 --- a/internal/msg_transfer/logic/init.go +++ b/internal/msg_transfer/logic/init.go @@ -40,8 +40,8 @@ var ( func Init() { cmdCh = make(chan Cmd2Value, 10000) w = new(sync.Mutex) - persistentCH.Init() // 订阅ws2mschat 消费到 mysql - historyCH.Init(cmdCh) // 订阅ws2mschat 如果可靠性存储 消费到 incrseq 再存入mongo 再push || 非可靠性 直接incr再push 初始化ws2mschat + persistentCH.Init() // ws2mschat save mysql + historyCH.Init(cmdCh) // historyMongoCH.Init() onlineTopicStatus = OnlineTopicVacancy //offlineHistoryCH.Init(cmdCh) diff --git a/internal/msg_transfer/logic/persistent_msg_handler.go b/internal/msg_transfer/logic/persistent_msg_handler.go index 817b3edb9..7b45e9234 100644 --- a/internal/msg_transfer/logic/persistent_msg_handler.go +++ b/internal/msg_transfer/logic/persistent_msg_handler.go @@ -42,7 +42,6 @@ func (pc *PersistentConsumerHandler) Init() { Name: "insert_mysql_msg_total", Help: "The total number of msg insert mysql events", }) - prometheus.MustRegister(msgInsertMysqlProcessed) } } @@ -79,8 +78,10 @@ func (pc *PersistentConsumerHandler) handleChatWs2Mysql(cMsg *sarama.ConsumerMes log.NewError(msgFromMQ.OperationID, "Message insert failed", "err", err.Error(), "msg", msgFromMQ.String()) return } + msgInsertMysqlProcessed.Inc() + msgInsertMysqlProcessed.Add(1) if config.Config.Prometheus.Enable { - log.NewDebug(msgFromMQ.OperationID, utils.GetSelfFuncName(), "inc msgInsertMysqlProcessed") + log.NewDebug(msgFromMQ.OperationID, utils.GetSelfFuncName(), "inc msgInsertMysqlProcessed", msgInsertMysqlProcessed.Desc()) msgInsertMysqlProcessed.Inc() } } diff --git a/pkg/base_info/group_api_struct.go b/pkg/base_info/group_api_struct.go index 8f2eaccd4..f2703bba2 100644 --- a/pkg/base_info/group_api_struct.go +++ b/pkg/base_info/group_api_struct.go @@ -16,7 +16,7 @@ type CommDataResp struct { type KickGroupMemberReq struct { GroupID string `json:"groupID" binding:"required"` - KickedUserIDList []string `json:"kickedUserIDList" binding:"required"` + KickedUserIDList []string `json:"kickedUserIDList" binding:"required, min=1, max=100"` Reason string `json:"reason"` OperationID string `json:"operationID" binding:"required"` } @@ -38,7 +38,7 @@ type GetGroupMembersInfoResp struct { type InviteUserToGroupReq struct { GroupID string `json:"groupID" binding:"required"` - InvitedUserIDList []string `json:"invitedUserIDList" binding:"required"` + InvitedUserIDList []string `json:"invitedUserIDList" binding:"required, min=1, max=100"` Reason string `json:"reason"` OperationID string `json:"operationID" binding:"required"` } diff --git a/pkg/common/db/mysql_model/im_mysql_model/group_member_model.go b/pkg/common/db/mysql_model/im_mysql_model/group_member_model.go index 341094d5d..25131f6a5 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/group_member_model.go +++ b/pkg/common/db/mysql_model/im_mysql_model/group_member_model.go @@ -35,8 +35,6 @@ func InsertIntoGroupMember(toInsertInfo db.GroupMember) error { } func BatchInsertIntoGroupMember(toInsertInfoList []*db.GroupMember) error { - //MessageList []*model_struct.LocalChatLog - //return utils.Wrap(d.conn.Create(MessageList).Error, "BatchInsertMessageList failed") for _, toInsertInfo := range toInsertInfoList { toInsertInfo.JoinTime = time.Now() if toInsertInfo.RoleLevel == 0 { diff --git a/pkg/utils/strings.go b/pkg/utils/strings.go index 5580f2838..203af2708 100644 --- a/pkg/utils/strings.go +++ b/pkg/utils/strings.go @@ -107,3 +107,15 @@ func int64ToString(i int64) string { func Int64ToString(i int64) string { return strconv.FormatInt(i, 10) } + +func RemoveDuplicateElement(idList []string) []string { + result := make([]string, 0, len(idList)) + temp := map[string]struct{}{} + for _, item := range idList { + if _, ok := temp[item]; !ok { + temp[item] = struct{}{} + result = append(result, item) + } + } + return result +}