mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
group update batch
This commit is contained in:
parent
5da1195274
commit
d6d6afb788
@ -117,7 +117,7 @@ const docTemplate = `{
|
|||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"Data": {
|
"Map": {
|
||||||
"$ref": "#/definitions/api_struct.ExpireTime"
|
"$ref": "#/definitions/api_struct.ExpireTime"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4369,7 +4369,7 @@ const docTemplate = `{
|
|||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"Data": {
|
"Map": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/definitions/server_api_params.PublicUserInfo"
|
"$ref": "#/definitions/server_api_params.PublicUserInfo"
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/tokenverify"
|
"Open_IM/pkg/common/tokenverify"
|
||||||
"Open_IM/pkg/getcdv3"
|
|
||||||
rpc "Open_IM/pkg/proto/auth"
|
rpc "Open_IM/pkg/proto/auth"
|
||||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
@ -149,7 +148,7 @@ func UserToken(c *gin.Context) {
|
|||||||
// @Param token header string true "im token"
|
// @Param token header string true "im token"
|
||||||
// @Param req body api.ParseTokenReq true "secret为openIM密钥, 详细见服务端config.yaml secret字段<br>platform为平台ID"
|
// @Param req body api.ParseTokenReq true "secret为openIM密钥, 详细见服务端config.yaml secret字段<br>platform为平台ID"
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Success 0 {object} api.ParseTokenResp{Data=api.ExpireTime}
|
// @Success 0 {object} api.ParseTokenResp{Map=api.ExpireTime}
|
||||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||||
// @Router /auth/parse_token [post]
|
// @Router /auth/parse_token [post]
|
||||||
|
@ -343,7 +343,7 @@ package friend
|
|||||||
// utils.CopyStructFields(&black, v)
|
// utils.CopyStructFields(&black, v)
|
||||||
// resp.BlackUserInfoList = append(resp.BlackUserInfoList, &black)
|
// resp.BlackUserInfoList = append(resp.BlackUserInfoList, &black)
|
||||||
// }
|
// }
|
||||||
// resp.Data = jsonData.JsonDataList(resp.BlackUserInfoList)
|
// resp.Map = jsonData.JsonDataList(resp.BlackUserInfoList)
|
||||||
// log.NewInfo(req.CommID.OperationID, "GetBlacklist api return ", resp)
|
// log.NewInfo(req.CommID.OperationID, "GetBlacklist api return ", resp)
|
||||||
// c.JSON(http.StatusOK, resp)
|
// c.JSON(http.StatusOK, resp)
|
||||||
//}
|
//}
|
||||||
@ -561,7 +561,7 @@ package friend
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// resp := api.GetFriendListResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, FriendInfoList: RpcResp.FriendInfoList}
|
// resp := api.GetFriendListResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, FriendInfoList: RpcResp.FriendInfoList}
|
||||||
// resp.Data = jsonData.JsonDataList(resp.FriendInfoList)
|
// resp.Map = jsonData.JsonDataList(resp.FriendInfoList)
|
||||||
// log.NewInfo(req.CommID.OperationID, "GetFriendList api return ", resp)
|
// log.NewInfo(req.CommID.OperationID, "GetFriendList api return ", resp)
|
||||||
// c.JSON(http.StatusOK, resp)
|
// c.JSON(http.StatusOK, resp)
|
||||||
// //c.JSON(http.StatusOK, resp)
|
// //c.JSON(http.StatusOK, resp)
|
||||||
@ -618,7 +618,7 @@ package friend
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// resp := api.GetFriendApplyListResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, FriendRequestList: RpcResp.FriendRequestList}
|
// resp := api.GetFriendApplyListResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, FriendRequestList: RpcResp.FriendRequestList}
|
||||||
// resp.Data = jsonData.JsonDataList(resp.FriendRequestList)
|
// resp.Map = jsonData.JsonDataList(resp.FriendRequestList)
|
||||||
// log.NewInfo(req.CommID.OperationID, "GetFriendApplyList api return ", resp)
|
// log.NewInfo(req.CommID.OperationID, "GetFriendApplyList api return ", resp)
|
||||||
// c.JSON(http.StatusOK, resp)
|
// c.JSON(http.StatusOK, resp)
|
||||||
//}
|
//}
|
||||||
@ -672,7 +672,7 @@ package friend
|
|||||||
// return
|
// return
|
||||||
// }
|
// }
|
||||||
// resp := api.GetSelfApplyListResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, FriendRequestList: RpcResp.FriendRequestList}
|
// resp := api.GetSelfApplyListResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, FriendRequestList: RpcResp.FriendRequestList}
|
||||||
// resp.Data = jsonData.JsonDataList(resp.FriendRequestList)
|
// resp.Map = jsonData.JsonDataList(resp.FriendRequestList)
|
||||||
// log.NewInfo(req.CommID.OperationID, "GetSelfApplyList api return ", resp)
|
// log.NewInfo(req.CommID.OperationID, "GetSelfApplyList api return ", resp)
|
||||||
// c.JSON(http.StatusOK, resp)
|
// c.JSON(http.StatusOK, resp)
|
||||||
//}
|
//}
|
||||||
|
@ -142,7 +142,7 @@ package group
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// memberListResp := api.GetGroupMembersInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, MemberList: RpcResp.MemberList}
|
// memberListResp := api.GetGroupMembersInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, MemberList: RpcResp.MemberList}
|
||||||
// memberListResp.Data = jsonData.JsonDataList(RpcResp.MemberList)
|
// memberListResp.Map = jsonData.JsonDataList(RpcResp.MemberList)
|
||||||
// log.NewInfo(req.OperationID, "GetGroupMembersInfo api return ", memberListResp)
|
// log.NewInfo(req.OperationID, "GetGroupMembersInfo api return ", memberListResp)
|
||||||
// c.JSON(http.StatusOK, memberListResp)
|
// c.JSON(http.StatusOK, memberListResp)
|
||||||
//}
|
//}
|
||||||
@ -186,7 +186,7 @@ package group
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// memberListResp := api.GetGroupMemberListResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, MemberList: RpcResp.MemberList, NextSeq: RpcResp.NextSeq}
|
// memberListResp := api.GetGroupMemberListResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, MemberList: RpcResp.MemberList, NextSeq: RpcResp.NextSeq}
|
||||||
// memberListResp.Data = jsonData.JsonDataList(memberListResp.MemberList)
|
// memberListResp.Map = jsonData.JsonDataList(memberListResp.MemberList)
|
||||||
//
|
//
|
||||||
// log.NewInfo(req.OperationID, "FindGroupMemberAll api return ", memberListResp)
|
// log.NewInfo(req.OperationID, "FindGroupMemberAll api return ", memberListResp)
|
||||||
// c.JSON(http.StatusOK, memberListResp)
|
// c.JSON(http.StatusOK, memberListResp)
|
||||||
@ -243,7 +243,7 @@ package group
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// memberListResp := api.GetGroupAllMemberResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, MemberList: RpcResp.MemberList}
|
// memberListResp := api.GetGroupAllMemberResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, MemberList: RpcResp.MemberList}
|
||||||
// memberListResp.Data = jsonData.JsonDataList(memberListResp.MemberList)
|
// memberListResp.Map = jsonData.JsonDataList(memberListResp.MemberList)
|
||||||
// log.NewInfo(req.OperationID, "GetGroupAllMember api return ", len(memberListResp.MemberList))
|
// log.NewInfo(req.OperationID, "GetGroupAllMember api return ", len(memberListResp.MemberList))
|
||||||
// c.JSON(http.StatusOK, memberListResp)
|
// c.JSON(http.StatusOK, memberListResp)
|
||||||
//}
|
//}
|
||||||
@ -298,7 +298,7 @@ package group
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// GroupListResp := api.GetJoinedGroupListResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, GroupInfoList: RpcResp.GroupList}
|
// GroupListResp := api.GetJoinedGroupListResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, GroupInfoList: RpcResp.GroupList}
|
||||||
// GroupListResp.Data = jsonData.JsonDataList(GroupListResp.GroupInfoList)
|
// GroupListResp.Map = jsonData.JsonDataList(GroupListResp.GroupInfoList)
|
||||||
// log.NewInfo(req.OperationID, "FindJoinedGroup api return ", GroupListResp)
|
// log.NewInfo(req.OperationID, "FindJoinedGroup api return ", GroupListResp)
|
||||||
// c.JSON(http.StatusOK, GroupListResp)
|
// c.JSON(http.StatusOK, GroupListResp)
|
||||||
//}
|
//}
|
||||||
@ -437,7 +437,7 @@ package group
|
|||||||
//// resp := api.CreateGroupResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
|
//// resp := api.CreateGroupResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
|
||||||
//// if RpcResp.ErrCode == 0 {
|
//// if RpcResp.ErrCode == 0 {
|
||||||
//// utils.CopyStructFields(&resp.GroupInfo, RpcResp.GroupInfo)
|
//// utils.CopyStructFields(&resp.GroupInfo, RpcResp.GroupInfo)
|
||||||
//// resp.Data = jsonData.JsonDataOne(&resp.GroupInfo)
|
//// resp.Map = jsonData.JsonDataOne(&resp.GroupInfo)
|
||||||
//// }
|
//// }
|
||||||
//// log.NewInfo(req.OperationID, "CreateGroup api return ", resp)
|
//// log.NewInfo(req.OperationID, "CreateGroup api return ", resp)
|
||||||
//// c.JSON(http.StatusOK, resp)
|
//// c.JSON(http.StatusOK, resp)
|
||||||
@ -496,7 +496,7 @@ package group
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// resp := api.GetGroupApplicationListResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}, GroupRequestList: reply.GroupRequestList}
|
// resp := api.GetGroupApplicationListResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}, GroupRequestList: reply.GroupRequestList}
|
||||||
// resp.Data = jsonData.JsonDataList(resp.GroupRequestList)
|
// resp.Map = jsonData.JsonDataList(resp.GroupRequestList)
|
||||||
// log.NewInfo(req.OperationID, "GetGroupApplicationList api return ", resp)
|
// log.NewInfo(req.OperationID, "GetGroupApplicationList api return ", resp)
|
||||||
// c.JSON(http.StatusOK, resp)
|
// c.JSON(http.StatusOK, resp)
|
||||||
//}
|
//}
|
||||||
@ -567,7 +567,7 @@ package group
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// resp := api.GetGroupInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, GroupInfoList: RpcResp.GroupInfoList}
|
// resp := api.GetGroupInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, GroupInfoList: RpcResp.GroupInfoList}
|
||||||
// resp.Data = jsonData.JsonDataList(resp.GroupInfoList)
|
// resp.Map = jsonData.JsonDataList(resp.GroupInfoList)
|
||||||
// log.NewInfo(req.OperationID, "GetGroupsInfo api return ", resp)
|
// log.NewInfo(req.OperationID, "GetGroupsInfo api return ", resp)
|
||||||
// c.JSON(http.StatusOK, resp)
|
// c.JSON(http.StatusOK, resp)
|
||||||
//}
|
//}
|
||||||
|
@ -46,7 +46,7 @@ package group
|
|||||||
// return
|
// return
|
||||||
// }
|
// }
|
||||||
// GroupListResp := api.GetJoinedSuperGroupListResp{GetJoinedGroupListResp: api.GetJoinedGroupListResp{CommResp: api.CommResp{ErrCode: rpcResp.CommonResp.ErrCode, ErrMsg: rpcResp.CommonResp.ErrMsg}, GroupInfoList: rpcResp.GroupList}}
|
// GroupListResp := api.GetJoinedSuperGroupListResp{GetJoinedGroupListResp: api.GetJoinedGroupListResp{CommResp: api.CommResp{ErrCode: rpcResp.CommonResp.ErrCode, ErrMsg: rpcResp.CommonResp.ErrMsg}, GroupInfoList: rpcResp.GroupList}}
|
||||||
// GroupListResp.Data = jsonData.JsonDataList(GroupListResp.GroupInfoList)
|
// GroupListResp.Map = jsonData.JsonDataList(GroupListResp.GroupInfoList)
|
||||||
// log.NewInfo(req.OperationID, "GetJoinedSuperGroupList api return ", GroupListResp)
|
// log.NewInfo(req.OperationID, "GetJoinedSuperGroupList api return ", GroupListResp)
|
||||||
// c.JSON(http.StatusOK, GroupListResp)
|
// c.JSON(http.StatusOK, GroupListResp)
|
||||||
//}
|
//}
|
||||||
@ -83,7 +83,7 @@ package group
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// resp := api.GetSuperGroupsInfoResp{GetGroupInfoResp: api.GetGroupInfoResp{CommResp: api.CommResp{ErrCode: rpcResp.CommonResp.ErrCode, ErrMsg: rpcResp.CommonResp.ErrMsg}, GroupInfoList: rpcResp.GroupInfoList}}
|
// resp := api.GetSuperGroupsInfoResp{GetGroupInfoResp: api.GetGroupInfoResp{CommResp: api.CommResp{ErrCode: rpcResp.CommonResp.ErrCode, ErrMsg: rpcResp.CommonResp.ErrMsg}, GroupInfoList: rpcResp.GroupInfoList}}
|
||||||
// resp.Data = jsonData.JsonDataList(resp.GroupInfoList)
|
// resp.Map = jsonData.JsonDataList(resp.GroupInfoList)
|
||||||
// log.NewInfo(req.OperationID, "GetGroupsInfo api return ", resp)
|
// log.NewInfo(req.OperationID, "GetGroupsInfo api return ", resp)
|
||||||
// c.JSON(http.StatusOK, resp)
|
// c.JSON(http.StatusOK, resp)
|
||||||
//}
|
//}
|
||||||
|
@ -13,7 +13,6 @@ import (
|
|||||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/tokenverify"
|
"Open_IM/pkg/common/tokenverify"
|
||||||
"Open_IM/pkg/getcdv3"
|
|
||||||
pbChat "Open_IM/pkg/proto/msg"
|
pbChat "Open_IM/pkg/proto/msg"
|
||||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
@ -165,7 +164,7 @@ func ManagementSendMsg(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
if err := mapstructure.WeakDecode(params.Content, &data); err != nil {
|
if err := mapstructure.WeakDecode(params.Content, &data); err != nil {
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": 401, "errMsg": err.Error()})
|
c.JSON(http.StatusOK, gin.H{"errCode": 401, "errMsg": err.Error()})
|
||||||
log.Error(c.PostForm("operationID"), "content to Data struct err", err.Error())
|
log.Error(c.PostForm("operationID"), "content to Map struct err", err.Error())
|
||||||
return
|
return
|
||||||
} else if err := validate.Struct(data); err != nil {
|
} else if err := validate.Struct(data); err != nil {
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": 403, "errMsg": err.Error()})
|
c.JSON(http.StatusOK, gin.H{"errCode": 403, "errMsg": err.Error()})
|
||||||
@ -298,7 +297,7 @@ func ManagementBatchSendMsg(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
if err := mapstructure.WeakDecode(params.Content, &data); err != nil {
|
if err := mapstructure.WeakDecode(params.Content, &data); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": err.Error()})
|
||||||
log.Error(c.PostForm("operationID"), "content to Data struct err", err.Error())
|
log.Error(c.PostForm("operationID"), "content to Map struct err", err.Error())
|
||||||
return
|
return
|
||||||
} else if err := validate.Struct(data); err != nil {
|
} else if err := validate.Struct(data); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 403, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 403, "errMsg": err.Error()})
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/tokenverify"
|
"Open_IM/pkg/common/tokenverify"
|
||||||
"Open_IM/pkg/getcdv3"
|
|
||||||
pbOffice "Open_IM/pkg/proto/office"
|
pbOffice "Open_IM/pkg/proto/office"
|
||||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
@ -565,7 +564,7 @@ func GetUserFriendWorkMoments(c *gin.Context) {
|
|||||||
if err := utils.CopyStructFields(&resp, respPb.CommonResp); err != nil {
|
if err := utils.CopyStructFields(&resp, respPb.CommonResp); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
//if err := utils.CopyStructFields(&resp.Data.WorkMoments, respPb.WorkMoments); err != nil {
|
//if err := utils.CopyStructFields(&resp.Map.WorkMoments, respPb.WorkMoments); err != nil {
|
||||||
// log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
// log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
//}
|
//}
|
||||||
resp.Data.WorkMoments = []*api.WorkMoment{}
|
resp.Data.WorkMoments = []*api.WorkMoment{}
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/tokenverify"
|
"Open_IM/pkg/common/tokenverify"
|
||||||
"Open_IM/pkg/getcdv3"
|
|
||||||
cacheRpc "Open_IM/pkg/proto/cache"
|
cacheRpc "Open_IM/pkg/proto/cache"
|
||||||
pbRelay "Open_IM/pkg/proto/relay"
|
pbRelay "Open_IM/pkg/proto/relay"
|
||||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||||
@ -156,7 +155,7 @@ func GetBlackIDListFromCache(c *gin.Context) {
|
|||||||
// @Param token header string true "im token"
|
// @Param token header string true "im token"
|
||||||
// @Param req body api.GetUsersInfoReq true "请求体"
|
// @Param req body api.GetUsersInfoReq true "请求体"
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Success 0 {object} api.GetUsersInfoResp{Data=[]open_im_sdk.PublicUserInfo}
|
// @Success 0 {object} api.GetUsersInfoResp{Map=[]open_im_sdk.PublicUserInfo}
|
||||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||||
// @Router /user/get_users_info [post]
|
// @Router /user/get_users_info [post]
|
||||||
|
@ -62,7 +62,7 @@ func (ws *WServer) argsValidate(m *Req, r int32, operationID string) (isPass boo
|
|||||||
case constant.WSGetNewestSeq:
|
case constant.WSGetNewestSeq:
|
||||||
data := open_im_sdk.GetMaxAndMinSeqReq{}
|
data := open_im_sdk.GetMaxAndMinSeqReq{}
|
||||||
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
||||||
log.Error(operationID, "Decode Data struct err", err.Error(), r)
|
log.Error(operationID, "Decode Map struct err", err.Error(), r)
|
||||||
return false, 203, err.Error(), nil
|
return false, 203, err.Error(), nil
|
||||||
}
|
}
|
||||||
if err := validate.Struct(data); err != nil {
|
if err := validate.Struct(data); err != nil {
|
||||||
@ -74,7 +74,7 @@ func (ws *WServer) argsValidate(m *Req, r int32, operationID string) (isPass boo
|
|||||||
case constant.WSSendMsg:
|
case constant.WSSendMsg:
|
||||||
data := open_im_sdk.MsgData{}
|
data := open_im_sdk.MsgData{}
|
||||||
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
||||||
log.Error(operationID, "Decode Data struct err", err.Error(), r)
|
log.Error(operationID, "Decode Map struct err", err.Error(), r)
|
||||||
return false, 203, err.Error(), nil
|
return false, 203, err.Error(), nil
|
||||||
}
|
}
|
||||||
if err := validate.Struct(data); err != nil {
|
if err := validate.Struct(data); err != nil {
|
||||||
@ -86,7 +86,7 @@ func (ws *WServer) argsValidate(m *Req, r int32, operationID string) (isPass boo
|
|||||||
case constant.WSSendSignalMsg:
|
case constant.WSSendSignalMsg:
|
||||||
data := pbRtc.SignalReq{}
|
data := pbRtc.SignalReq{}
|
||||||
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
||||||
log.Error(operationID, "Decode Data struct err", err.Error(), r)
|
log.Error(operationID, "Decode Map struct err", err.Error(), r)
|
||||||
return false, 203, err.Error(), nil
|
return false, 203, err.Error(), nil
|
||||||
}
|
}
|
||||||
if err := validate.Struct(data); err != nil {
|
if err := validate.Struct(data); err != nil {
|
||||||
@ -98,7 +98,7 @@ func (ws *WServer) argsValidate(m *Req, r int32, operationID string) (isPass boo
|
|||||||
case constant.WSPullMsgBySeqList:
|
case constant.WSPullMsgBySeqList:
|
||||||
data := open_im_sdk.PullMessageBySeqListReq{}
|
data := open_im_sdk.PullMessageBySeqListReq{}
|
||||||
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
||||||
log.Error(operationID, "Decode Data struct err", err.Error(), r)
|
log.Error(operationID, "Decode Map struct err", err.Error(), r)
|
||||||
return false, 203, err.Error(), nil
|
return false, 203, err.Error(), nil
|
||||||
}
|
}
|
||||||
if err := validate.Struct(data); err != nil {
|
if err := validate.Struct(data); err != nil {
|
||||||
@ -110,7 +110,7 @@ func (ws *WServer) argsValidate(m *Req, r int32, operationID string) (isPass boo
|
|||||||
case constant.WsSetBackgroundStatus:
|
case constant.WsSetBackgroundStatus:
|
||||||
data := open_im_sdk.SetAppBackgroundStatusReq{}
|
data := open_im_sdk.SetAppBackgroundStatusReq{}
|
||||||
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
||||||
log.Error(operationID, "Decode Data struct err", err.Error(), r)
|
log.Error(operationID, "Decode Map struct err", err.Error(), r)
|
||||||
return false, 203, err.Error(), nil
|
return false, 203, err.Error(), nil
|
||||||
}
|
}
|
||||||
if err := validate.Struct(data); err != nil {
|
if err := validate.Struct(data); err != nil {
|
||||||
|
@ -49,7 +49,7 @@ func GenSign(timeStamp uint64, accessId string, secretKey, requestBody string) s
|
|||||||
signBody := strconv.Itoa(int(timeStamp)) + accessId + requestBody
|
signBody := strconv.Itoa(int(timeStamp)) + accessId + requestBody
|
||||||
// Create a new HMAC by defining the hash type and the key (as byte array)
|
// Create a new HMAC by defining the hash type and the key (as byte array)
|
||||||
h := hmac.New(sha256.New, []byte(secretKey))
|
h := hmac.New(sha256.New, []byte(secretKey))
|
||||||
// Write Data to it
|
// Write Map to it
|
||||||
h.Write([]byte(signBody))
|
h.Write([]byte(signBody))
|
||||||
|
|
||||||
// Get result and encode as hexadecimal string
|
// Get result and encode as hexadecimal string
|
||||||
|
@ -119,7 +119,7 @@ func CallbackBeforeMemberJoinGroup(ctx context.Context, operationID string, grou
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func CallbackBeforeSetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGroupMemberInfoReq) (err error) {
|
func CallbackBeforeSetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGroupMemberInfo) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxInfo(ctx, utils.GetFuncName(1), err, "req", *req)
|
tracelog.SetCtxInfo(ctx, utils.GetFuncName(1), err, "req", *req)
|
||||||
}()
|
}()
|
||||||
|
@ -44,7 +44,7 @@ func UpdateGroupMemberMutedTimeMap(t time.Time) map[string]any {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateGroupMemberMap(req *pbGroup.SetGroupMemberInfoReq) map[string]any {
|
func UpdateGroupMemberMap(req *pbGroup.SetGroupMemberInfo) map[string]any {
|
||||||
m := make(map[string]any)
|
m := make(map[string]any)
|
||||||
if req.Nickname != nil {
|
if req.Nickname != nil {
|
||||||
m["nickname"] = req.Nickname.Value
|
m["nickname"] = req.Nickname.Value
|
||||||
|
@ -30,7 +30,6 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenIMSDK/openKeeper"
|
"github.com/OpenIMSDK/openKeeper"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/protobuf/types/known/wrapperspb"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type groupServer struct {
|
type groupServer struct {
|
||||||
@ -951,50 +950,79 @@ func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMu
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) SetGroupMemberNickname(ctx context.Context, req *pbGroup.SetGroupMemberNicknameReq) (*pbGroup.SetGroupMemberNicknameResp, error) {
|
|
||||||
_, err := s.SetGroupMemberInfo(ctx, &pbGroup.SetGroupMemberInfoReq{GroupID: req.GroupID, UserID: req.UserID, Nickname: wrapperspb.String(req.Nickname)})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &pbGroup.SetGroupMemberNicknameResp{}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGroupMemberInfoReq) (*pbGroup.SetGroupMemberInfoResp, error) {
|
func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGroupMemberInfoReq) (*pbGroup.SetGroupMemberInfoResp, error) {
|
||||||
resp := &pbGroup.SetGroupMemberInfoResp{}
|
resp := &pbGroup.SetGroupMemberInfoResp{}
|
||||||
if req.RoleLevel != nil && req.RoleLevel.Value == constant.GroupOwner {
|
if len(req.Members) == 0 {
|
||||||
return nil, constant.ErrNoPermission.Wrap("set group owner")
|
return nil, constant.ErrArgs.Wrap("members empty")
|
||||||
}
|
}
|
||||||
group, err := s.GroupInterface.TakeGroup(ctx, req.GroupID)
|
duplicateMap := make(map[[2]string]struct{})
|
||||||
if err != nil {
|
userIDMap := make(map[string]struct{})
|
||||||
return nil, err
|
groupIDMap := make(map[string]struct{})
|
||||||
}
|
for _, member := range req.Members {
|
||||||
if group.Status == constant.GroupStatusDismissed {
|
key := [...]string{member.GroupID, member.UserID}
|
||||||
return nil, constant.ErrArgs.Wrap("group status is dismissed")
|
if _, ok := duplicateMap[key]; ok {
|
||||||
}
|
return nil, constant.ErrArgs.Wrap("group user duplicate")
|
||||||
member, err := s.GroupInterface.TakeGroupMember(ctx, req.GroupID, req.UserID)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if tracelog.GetOpUserID(ctx) == req.UserID {
|
|
||||||
if req.RoleLevel != nil {
|
|
||||||
return nil, constant.ErrArgs.Wrap("update role level")
|
|
||||||
}
|
}
|
||||||
} else if !tokenverify.IsAppManagerUid(ctx) {
|
duplicateMap[key] = struct{}{}
|
||||||
opMember, err := s.GroupInterface.TakeGroupMember(ctx, req.GroupID, tracelog.GetOpUserID(ctx))
|
userIDMap[member.UserID] = struct{}{}
|
||||||
if err != nil {
|
groupIDMap[member.GroupID] = struct{}{}
|
||||||
|
}
|
||||||
|
groupIDs := utils.Keys(groupIDMap)
|
||||||
|
userIDs := utils.Keys(userIDMap)
|
||||||
|
members, err := s.GroupInterface.FindGroupMember(ctx, groupIDs, append(userIDs, tracelog.GetOpUserID(ctx)), nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, member := range members {
|
||||||
|
delete(duplicateMap, [...]string{member.GroupID, member.UserID})
|
||||||
|
}
|
||||||
|
if len(duplicateMap) > 0 {
|
||||||
|
return nil, constant.ErrArgs.Wrap("group not found or user not in group")
|
||||||
|
}
|
||||||
|
memberMap := utils.SliceToMap(members, func(e *relationTb.GroupMemberModel) [2]string {
|
||||||
|
return [...]string{e.GroupID, e.UserID}
|
||||||
|
})
|
||||||
|
if !tokenverify.IsAppManagerUid(ctx) {
|
||||||
|
opUserID := tracelog.GetOpUserID(ctx)
|
||||||
|
for _, member := range members {
|
||||||
|
if member.UserID == opUserID {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
opMember, ok := memberMap[[...]string{member.GroupID, member.UserID}]
|
||||||
|
if !ok {
|
||||||
|
return nil, constant.ErrArgs.Wrap(fmt.Sprintf("user %s not in group %s", opUserID, member.GroupID))
|
||||||
|
}
|
||||||
|
if member.RoleLevel >= opMember.RoleLevel {
|
||||||
|
return nil, constant.ErrNoPermission.Wrap(fmt.Sprintf("group %s : %s RoleLevel %d >= %s RoleLevel %d", member.GroupID, member.UserID, member.RoleLevel, opMember.UserID, opMember.RoleLevel))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, member := range req.Members {
|
||||||
|
if member.RoleLevel == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if memberMap[[...]string{member.GroupID, member.UserID}].RoleLevel == constant.GroupOwner {
|
||||||
|
return nil, constant.ErrArgs.Wrap(fmt.Sprintf("group %s user %s is owner", member.GroupID, member.UserID))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for i := 0; i < len(req.Members); i++ {
|
||||||
|
if err := CallbackBeforeSetGroupMemberInfo(ctx, req.Members[i]); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if opMember.RoleLevel <= member.RoleLevel {
|
}
|
||||||
return nil, constant.ErrNoPermission.Wrap(fmt.Sprintf("self RoleLevel %d target %d", opMember.RoleLevel, member.RoleLevel))
|
err = s.GroupInterface.UpdateGroupMembers(ctx, utils.Slice(req.Members, func(e *pbGroup.SetGroupMemberInfo) *controller.BatchUpdateGroupMember {
|
||||||
|
return &controller.BatchUpdateGroupMember{
|
||||||
|
GroupID: e.GroupID,
|
||||||
|
UserID: e.UserID,
|
||||||
|
Map: UpdateGroupMemberMap(e),
|
||||||
}
|
}
|
||||||
}
|
}))
|
||||||
if err := CallbackBeforeSetGroupMemberInfo(ctx, req); err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err := s.GroupInterface.UpdateGroupMember(ctx, req.GroupID, req.UserID, UpdateGroupMemberMap(req)); err != nil {
|
for _, member := range req.Members {
|
||||||
return nil, err
|
chat.GroupMemberInfoSetNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), member.GroupID, member.UserID)
|
||||||
}
|
}
|
||||||
chat.GroupMemberInfoSetNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID, req.UserID)
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ package apistruct
|
|||||||
//type GetBlackListResp struct {
|
//type GetBlackListResp struct {
|
||||||
// CommResp
|
// CommResp
|
||||||
// BlackUserInfoList []*open_im_sdk.PublicUserInfo `json:"-"`
|
// BlackUserInfoList []*open_im_sdk.PublicUserInfo `json:"-"`
|
||||||
// Data []map[string]interface{} `json:"data" swaggerignore:"true"`
|
// Map []map[string]interface{} `json:"data" swaggerignore:"true"`
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
////type PublicUserInfo struct {
|
////type PublicUserInfo struct {
|
||||||
@ -100,7 +100,7 @@ package apistruct
|
|||||||
//type GetFriendsInfoResp struct {
|
//type GetFriendsInfoResp struct {
|
||||||
// CommResp
|
// CommResp
|
||||||
// FriendInfoList []*open_im_sdk.FriendInfo `json:"-"`
|
// FriendInfoList []*open_im_sdk.FriendInfo `json:"-"`
|
||||||
// Data []map[string]interface{} `json:"data" swaggerignore:"true"`
|
// Map []map[string]interface{} `json:"data" swaggerignore:"true"`
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//type GetFriendListReq struct {
|
//type GetFriendListReq struct {
|
||||||
@ -110,7 +110,7 @@ package apistruct
|
|||||||
//type GetFriendListResp struct {
|
//type GetFriendListResp struct {
|
||||||
// CommResp
|
// CommResp
|
||||||
// FriendInfoList []*open_im_sdk.FriendInfo `json:"-"`
|
// FriendInfoList []*open_im_sdk.FriendInfo `json:"-"`
|
||||||
// Data []map[string]interface{} `json:"data" swaggerignore:"true"`
|
// Map []map[string]interface{} `json:"data" swaggerignore:"true"`
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//type GetFriendApplyListReq struct {
|
//type GetFriendApplyListReq struct {
|
||||||
@ -120,7 +120,7 @@ package apistruct
|
|||||||
//type GetFriendApplyListResp struct {
|
//type GetFriendApplyListResp struct {
|
||||||
// CommResp
|
// CommResp
|
||||||
// FriendRequestList []*open_im_sdk.FriendRequest `json:"-"`
|
// FriendRequestList []*open_im_sdk.FriendRequest `json:"-"`
|
||||||
// Data []map[string]interface{} `json:"data" swaggerignore:"true"`
|
// Map []map[string]interface{} `json:"data" swaggerignore:"true"`
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//type GetSelfApplyListReq struct {
|
//type GetSelfApplyListReq struct {
|
||||||
@ -130,7 +130,7 @@ package apistruct
|
|||||||
//type GetSelfApplyListResp struct {
|
//type GetSelfApplyListResp struct {
|
||||||
// CommResp
|
// CommResp
|
||||||
// FriendRequestList []*open_im_sdk.FriendRequest `json:"-"`
|
// FriendRequestList []*open_im_sdk.FriendRequest `json:"-"`
|
||||||
// Data []map[string]interface{} `json:"data" swaggerignore:"true"`
|
// Map []map[string]interface{} `json:"data" swaggerignore:"true"`
|
||||||
//}
|
//}
|
||||||
|
|
||||||
type FriendInfo struct {
|
type FriendInfo struct {
|
||||||
|
@ -92,7 +92,7 @@ type GetGroupAllMemberResp struct {
|
|||||||
//type GetGroupAllMemberListBySplitResp struct {
|
//type GetGroupAllMemberListBySplitResp struct {
|
||||||
// CommResp
|
// CommResp
|
||||||
// MemberList []*open_im_sdk.GroupMemberFullInfo `json:"-"`
|
// MemberList []*open_im_sdk.GroupMemberFullInfo `json:"-"`
|
||||||
// Data []map[string]interface{} `json:"data" swaggerignore:"true"`
|
// Map []map[string]interface{} `json:"data" swaggerignore:"true"`
|
||||||
//}
|
//}
|
||||||
|
|
||||||
type CreateGroupReq struct {
|
type CreateGroupReq struct {
|
||||||
|
23
pkg/common/db/cache/conversation.go
vendored
23
pkg/common/db/cache/conversation.go
vendored
@ -148,29 +148,6 @@ func (c *ConversationRedis) GetUserConversationIDs1(ctx context.Context, ownerUs
|
|||||||
// return t, nil
|
// return t, nil
|
||||||
//}
|
//}
|
||||||
|
|
||||||
func GetCache[T any](ctx context.Context, rcClient *rockscache.Client, key string, expire time.Duration, fn func(ctx context.Context) (T, error)) (T, error) {
|
|
||||||
v, err := rcClient.Fetch(key, expire, func() (string, error) {
|
|
||||||
v, err := fn(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
bs, err := json.Marshal(v)
|
|
||||||
if err != nil {
|
|
||||||
return "", utils.Wrap(err, "")
|
|
||||||
}
|
|
||||||
return string(bs), nil
|
|
||||||
})
|
|
||||||
var t T
|
|
||||||
if err != nil {
|
|
||||||
return t, err
|
|
||||||
}
|
|
||||||
err = json.Unmarshal([]byte(v), &t)
|
|
||||||
if err != nil {
|
|
||||||
return t, utils.Wrap(err, "")
|
|
||||||
}
|
|
||||||
return t, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *ConversationRedis) DelUserConversationIDs(ctx context.Context, ownerUserID string) (err error) {
|
func (c *ConversationRedis) DelUserConversationIDs(ctx context.Context, ownerUserID string) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID)
|
||||||
|
45
pkg/common/db/cache/group.go
vendored
45
pkg/common/db/cache/group.go
vendored
@ -56,16 +56,16 @@ type GroupCache interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GroupCacheRedis struct {
|
type GroupCacheRedis struct {
|
||||||
group *relation.GroupGorm
|
group relationTb.GroupModelInterface
|
||||||
groupMember *relation.GroupMemberGorm
|
groupMember relationTb.GroupMemberModelInterface
|
||||||
groupRequest *relation.GroupRequestGorm
|
groupRequest relationTb.GroupRequestModelInterface
|
||||||
mongoDB *unrelation.SuperGroupMongoDriver
|
mongoDB *unrelation.SuperGroupMongoDriver
|
||||||
expireTime time.Duration
|
expireTime time.Duration
|
||||||
redisClient *RedisClient
|
redisClient *RedisClient
|
||||||
rcClient *rockscache.Client
|
rcClient *rockscache.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGroupCacheRedis(rdb redis.UniversalClient, groupDB *relation.GroupGorm, groupMemberDB *relation.GroupMemberGorm, groupRequestDB *relation.GroupRequestGorm, mongoClient *unrelation.SuperGroupMongoDriver, opts rockscache.Options) *GroupCacheRedis {
|
func NewGroupCacheRedis(rdb redis.UniversalClient, groupDB relationTb.GroupModelInterface, groupMemberDB relationTb.GroupMemberModelInterface, groupRequestDB relationTb.GroupRequestModelInterface, mongoClient *unrelation.SuperGroupMongoDriver, opts rockscache.Options) *GroupCacheRedis {
|
||||||
return &GroupCacheRedis{rcClient: rockscache.NewClient(rdb, opts), expireTime: groupExpireTime,
|
return &GroupCacheRedis{rcClient: rockscache.NewClient(rdb, opts), expireTime: groupExpireTime,
|
||||||
group: groupDB, groupMember: groupMemberDB, groupRequest: groupRequestDB, redisClient: NewRedisClient(rdb),
|
group: groupDB, groupMember: groupMemberDB, groupRequest: groupRequestDB, redisClient: NewRedisClient(rdb),
|
||||||
mongoDB: mongoClient,
|
mongoDB: mongoClient,
|
||||||
@ -105,39 +105,16 @@ func (g *GroupCacheRedis) getGroupMemberNumKey(groupID string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// / groupInfo
|
// / groupInfo
|
||||||
func (g *GroupCacheRedis) GetGroupsInfo(ctx context.Context, groupIDs []string) (groups []*relation.Group, err error) {
|
func (g *GroupCacheRedis) GetGroupsInfo(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error) {
|
||||||
for _, groupID := range groupIDs {
|
return GetCacheFor(ctx, g.rcClient, groupIDs, func(ctx context.Context, groupID string) (*relationTb.GroupModel, error) {
|
||||||
group, err := g.GetGroupInfo(ctx, groupID)
|
return g.GetGroupInfo(ctx, groupID)
|
||||||
if err != nil {
|
})
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
groups = append(groups, group)
|
|
||||||
}
|
|
||||||
return groups, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupCacheRedis) GetGroupInfo(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error) {
|
func (g *GroupCacheRedis) GetGroupInfo(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error) {
|
||||||
getGroup := func() (string, error) {
|
return GetCache(ctx, g.rcClient, g.getGroupInfoKey(groupID), g.expireTime, func(ctx context.Context) (*relationTb.GroupModel, error) {
|
||||||
groupInfo, err := g.group.Take(ctx, groupID)
|
return g.group.Take(ctx, groupID)
|
||||||
if err != nil {
|
})
|
||||||
return "", utils.Wrap(err, "")
|
|
||||||
}
|
|
||||||
bytes, err := json.Marshal(groupInfo)
|
|
||||||
if err != nil {
|
|
||||||
return "", utils.Wrap(err, "")
|
|
||||||
}
|
|
||||||
return string(bytes), nil
|
|
||||||
}
|
|
||||||
group = &relationTb.GroupModel{}
|
|
||||||
defer func() {
|
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "group", *group)
|
|
||||||
}()
|
|
||||||
groupStr, err := g.rcClient.Fetch(g.getGroupInfoKey(groupID), g.expireTime, getGroup)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
err = json.Unmarshal([]byte(groupStr), group)
|
|
||||||
return group, utils.Wrap(err, "")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupCacheRedis) DelGroupInfo(ctx context.Context, groupID string) (err error) {
|
func (g *GroupCacheRedis) DelGroupInfo(ctx context.Context, groupID string) (err error) {
|
||||||
|
49
pkg/common/db/cache/utils.go
vendored
Normal file
49
pkg/common/db/cache/utils.go
vendored
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package cache
|
||||||
|
|
||||||
|
import (
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"github.com/dtm-labs/rockscache"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetCache[T any](ctx context.Context, rcClient *rockscache.Client, key string, expire time.Duration, fn func(ctx context.Context) (T, error)) (T, error) {
|
||||||
|
var t T
|
||||||
|
var write bool
|
||||||
|
v, err := rcClient.Fetch(key, expire, func() (s string, err error) {
|
||||||
|
t, err = fn(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
bs, err := json.Marshal(t)
|
||||||
|
if err != nil {
|
||||||
|
return "", utils.Wrap(err, "")
|
||||||
|
}
|
||||||
|
write = true
|
||||||
|
return string(bs), nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return t, err
|
||||||
|
}
|
||||||
|
if write {
|
||||||
|
return t, nil
|
||||||
|
}
|
||||||
|
err = json.Unmarshal([]byte(v), &t)
|
||||||
|
if err != nil {
|
||||||
|
return t, utils.Wrap(err, "")
|
||||||
|
}
|
||||||
|
return t, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetCacheFor[E any, T any](ctx context.Context, rcClient *rockscache.Client, list []E, fn func(ctx context.Context, item E) (T, error)) ([]T, error) {
|
||||||
|
rs := make([]T, 0, len(list))
|
||||||
|
for _, e := range list {
|
||||||
|
r, err := fn(ctx, e)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
rs = append(rs, r)
|
||||||
|
}
|
||||||
|
return rs, nil
|
||||||
|
}
|
@ -19,6 +19,12 @@ import (
|
|||||||
|
|
||||||
//type GroupInterface GroupDataBaseInterface
|
//type GroupInterface GroupDataBaseInterface
|
||||||
|
|
||||||
|
type BatchUpdateGroupMember struct {
|
||||||
|
GroupID string
|
||||||
|
UserID string
|
||||||
|
Map map[string]any
|
||||||
|
}
|
||||||
|
|
||||||
type GroupInterface interface {
|
type GroupInterface interface {
|
||||||
CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error
|
CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error
|
||||||
TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error)
|
TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error)
|
||||||
@ -38,7 +44,8 @@ type GroupInterface interface {
|
|||||||
MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string][]string, error)
|
MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string][]string, error)
|
||||||
MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error)
|
MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error)
|
||||||
TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string, roleLevel int32) error // 转让群
|
TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string, roleLevel int32) error // 转让群
|
||||||
UpdateGroupMember(ctx context.Context, groupID, userID string, data map[string]any) error
|
UpdateGroupMember(ctx context.Context, groupID string, userID string, data map[string]any) error
|
||||||
|
UpdateGroupMembers(ctx context.Context, data []*BatchUpdateGroupMember) error
|
||||||
// GroupRequest
|
// GroupRequest
|
||||||
CreateGroupRequest(ctx context.Context, requests []*relationTb.GroupRequestModel) error
|
CreateGroupRequest(ctx context.Context, requests []*relationTb.GroupRequestModel) error
|
||||||
TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relationTb.GroupRequestModel, error)
|
TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relationTb.GroupRequestModel, error)
|
||||||
@ -130,7 +137,11 @@ func (g *GroupController) TransferGroupOwner(ctx context.Context, groupID string
|
|||||||
return g.database.TransferGroupOwner(ctx, groupID, oldOwnerUserID, newOwnerUserID, roleLevel)
|
return g.database.TransferGroupOwner(ctx, groupID, oldOwnerUserID, newOwnerUserID, roleLevel)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupController) UpdateGroupMember(ctx context.Context, groupID, userID string, data map[string]any) error {
|
func (g *GroupController) UpdateGroupMembers(ctx context.Context, data []*BatchUpdateGroupMember) error {
|
||||||
|
return g.database.UpdateGroupMembers(ctx, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *GroupController) UpdateGroupMember(ctx context.Context, groupID string, userID string, data map[string]any) error {
|
||||||
return g.database.UpdateGroupMember(ctx, groupID, userID, data)
|
return g.database.UpdateGroupMember(ctx, groupID, userID, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,9 +157,6 @@ func (g *GroupController) PageGroupRequestUser(ctx context.Context, userID strin
|
|||||||
return g.database.PageGroupRequestUser(ctx, userID, pageNumber, showNumber)
|
return g.database.PageGroupRequestUser(ctx, userID, pageNumber, showNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
// func (g *GroupController) TakeSuperGroup(ctx context.Context, groupID string) (superGroup *unrelationTb.SuperGroupModel, err error) {
|
|
||||||
// return g.database.TakeSuperGroup(ctx, groupID)
|
|
||||||
// }
|
|
||||||
func (g *GroupController) FindSuperGroup(ctx context.Context, groupIDs []string) ([]*unrelationTb.SuperGroupModel, error) {
|
func (g *GroupController) FindSuperGroup(ctx context.Context, groupIDs []string) ([]*unrelationTb.SuperGroupModel, error) {
|
||||||
return g.database.FindSuperGroup(ctx, groupIDs)
|
return g.database.FindSuperGroup(ctx, groupIDs)
|
||||||
}
|
}
|
||||||
@ -192,7 +200,8 @@ type GroupDataBaseInterface interface {
|
|||||||
MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string][]string, error)
|
MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string][]string, error)
|
||||||
MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error)
|
MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error)
|
||||||
TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string, roleLevel int32) error // 转让群
|
TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string, roleLevel int32) error // 转让群
|
||||||
UpdateGroupMember(ctx context.Context, groupID, userID string, data map[string]any) error
|
UpdateGroupMember(ctx context.Context, groupID string, userID string, data map[string]any) error
|
||||||
|
UpdateGroupMembers(ctx context.Context, data []*BatchUpdateGroupMember) error
|
||||||
// GroupRequest
|
// GroupRequest
|
||||||
CreateGroupRequest(ctx context.Context, requests []*relationTb.GroupRequestModel) error
|
CreateGroupRequest(ctx context.Context, requests []*relationTb.GroupRequestModel) error
|
||||||
TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relationTb.GroupRequestModel, error)
|
TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relationTb.GroupRequestModel, error)
|
||||||
@ -217,7 +226,7 @@ func NewGroupDatabase(db *gorm.DB, rdb redis.UniversalClient, mgoClient *mongo.C
|
|||||||
groupMemberDB: groupMemberDB,
|
groupMemberDB: groupMemberDB,
|
||||||
groupRequestDB: groupRequestDB,
|
groupRequestDB: groupRequestDB,
|
||||||
db: &newDB,
|
db: &newDB,
|
||||||
cache: cache.NewGroupCache(rdb, groupDB, groupMemberDB, groupRequestDB, SuperGroupMongoDriver, rockscache.Options{
|
cache: cache.NewGroupCacheRedis(rdb, groupDB, groupMemberDB, groupRequestDB, SuperGroupMongoDriver, rockscache.Options{
|
||||||
RandomExpireAdjustment: 0.2,
|
RandomExpireAdjustment: 0.2,
|
||||||
DisableCacheRead: false,
|
DisableCacheRead: false,
|
||||||
DisableCacheDelete: false,
|
DisableCacheDelete: false,
|
||||||
@ -408,7 +417,7 @@ func (g *GroupDataBase) TransferGroupOwner(ctx context.Context, groupID string,
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupDataBase) UpdateGroupMember(ctx context.Context, groupID, userID string, data map[string]any) error {
|
func (g *GroupDataBase) UpdateGroupMember(ctx context.Context, groupID string, userID string, data map[string]any) error {
|
||||||
return g.db.Transaction(func(tx *gorm.DB) error {
|
return g.db.Transaction(func(tx *gorm.DB) error {
|
||||||
if err := g.groupMemberDB.Update(ctx, groupID, userID, data, tx); err != nil {
|
if err := g.groupMemberDB.Update(ctx, groupID, userID, data, tx); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -420,6 +429,20 @@ func (g *GroupDataBase) UpdateGroupMember(ctx context.Context, groupID, userID s
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *GroupDataBase) UpdateGroupMembers(ctx context.Context, data []*BatchUpdateGroupMember) error {
|
||||||
|
return g.db.Transaction(func(tx *gorm.DB) error {
|
||||||
|
for _, item := range data {
|
||||||
|
if err := g.groupMemberDB.Update(ctx, item.GroupID, item.UserID, item.Map, tx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := g.cache.DelGroupMemberInfo(ctx, item.GroupID, item.UserID); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (g *GroupDataBase) CreateGroupRequest(ctx context.Context, requests []*relationTb.GroupRequestModel) error {
|
func (g *GroupDataBase) CreateGroupRequest(ctx context.Context, requests []*relationTb.GroupRequestModel) error {
|
||||||
return g.groupRequestDB.Create(ctx, requests)
|
return g.groupRequestDB.Create(ctx, requests)
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ func (f *fileHook) Levels() []logrus.Level {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//func (f *fileHook) Fire(entry *logrus.Entry) error {
|
//func (f *fileHook) Fire(entry *logrus.Entry) error {
|
||||||
// entry.Data["FilePath"] = findCaller(6)
|
// entry.Map["FilePath"] = findCaller(6)
|
||||||
// utils.GetSelfFuncName()
|
// utils.GetSelfFuncName()
|
||||||
// return nil
|
// return nil
|
||||||
//}
|
//}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -227,17 +227,6 @@ message CancelMuteGroupReq{
|
|||||||
message CancelMuteGroupResp{
|
message CancelMuteGroupResp{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
message SetGroupMemberNicknameReq{
|
|
||||||
string groupID = 1;
|
|
||||||
string nickname = 2;
|
|
||||||
string userID = 3;
|
|
||||||
}
|
|
||||||
message SetGroupMemberNicknameResp{
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetJoinedSuperGroupListReq {
|
message GetJoinedSuperGroupListReq {
|
||||||
string userID = 1;
|
string userID = 1;
|
||||||
}
|
}
|
||||||
@ -254,7 +243,7 @@ message GetSuperGroupsInfoResp {
|
|||||||
repeated server_api_params.GroupInfo groupInfos = 1;
|
repeated server_api_params.GroupInfo groupInfos = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message SetGroupMemberInfoReq{
|
message SetGroupMemberInfo{
|
||||||
string groupID = 1;
|
string groupID = 1;
|
||||||
string userID = 2;
|
string userID = 2;
|
||||||
google.protobuf.StringValue nickname = 3;
|
google.protobuf.StringValue nickname = 3;
|
||||||
@ -263,6 +252,10 @@ message SetGroupMemberInfoReq{
|
|||||||
google.protobuf.StringValue ex = 6;
|
google.protobuf.StringValue ex = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message SetGroupMemberInfoReq{
|
||||||
|
repeated SetGroupMemberInfo members = 1;
|
||||||
|
}
|
||||||
|
|
||||||
message SetGroupMemberInfoResp{
|
message SetGroupMemberInfoResp{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -348,7 +341,6 @@ service group{
|
|||||||
//获取指定的超级群信息
|
//获取指定的超级群信息
|
||||||
rpc getSuperGroupsInfo(GetSuperGroupsInfoReq) returns (GetSuperGroupsInfoResp);
|
rpc getSuperGroupsInfo(GetSuperGroupsInfoReq) returns (GetSuperGroupsInfoResp);
|
||||||
//设置群成员昵称
|
//设置群成员昵称
|
||||||
rpc setGroupMemberNickname(SetGroupMemberNicknameReq) returns (SetGroupMemberNicknameResp);
|
|
||||||
//设置群成员信息
|
//设置群成员信息
|
||||||
rpc setGroupMemberInfo(SetGroupMemberInfoReq) returns (SetGroupMemberInfoResp);
|
rpc setGroupMemberInfo(SetGroupMemberInfoReq) returns (SetGroupMemberInfoResp);
|
||||||
//获取群信息hash值
|
//获取群信息hash值
|
||||||
|
Loading…
x
Reference in New Issue
Block a user