mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-04 09:05:59 +08:00
Merge remote-tracking branch 'origin/errcode' into errcode
This commit is contained in:
+10
-10
@@ -7,7 +7,7 @@ import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/common/trace_log"
|
||||
"Open_IM/pkg/common/tracelog"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
rpc "Open_IM/pkg/proto/group"
|
||||
"Open_IM/pkg/utils"
|
||||
@@ -996,35 +996,35 @@ func MuteGroupMember(c *gin.Context) {
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /group/cancel_mute_group_member [post]
|
||||
func CancelMuteGroupMember(c *gin.Context) {
|
||||
nCtx := trace_log.NewCtx(c, utils.GetSelfFuncName())
|
||||
nCtx := tracelog.NewCtx(c, utils.GetSelfFuncName())
|
||||
defer log.ShowLog(c)
|
||||
|
||||
params := api.CancelMuteGroupMemberReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
trace_log.WriteErrorResponse(nCtx, "BindJSON", err)
|
||||
tracelog.WriteErrorResponse(nCtx, "BindJSON", err)
|
||||
return
|
||||
}
|
||||
trace_log.SetCtxInfo(nCtx, "BindJSON", nil, "params", params)
|
||||
tracelog.SetCtxInfo(nCtx, "BindJSON", nil, "params", params)
|
||||
req := &rpc.CancelMuteGroupMemberReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
|
||||
//var err error
|
||||
//if err, req.OpUserID, _ = token_verify.ParseUserIDFromToken(c.Request.Header.Get("token"), req.OperationID); err != nil {
|
||||
// trace_log.WriteErrorResponse(nCtx, "ParseUserIDFromToken", err)
|
||||
// tracelog.WriteErrorResponse(nCtx, "ParseUserIDFromToken", err)
|
||||
// return
|
||||
//}
|
||||
trace_log.SetCtxInfo(nCtx, "ParseUserIDFromToken", nil, "token", c.Request.Header.Get("token"), "OpUserID", req.OpUserID)
|
||||
tracelog.SetCtxInfo(nCtx, "ParseUserIDFromToken", nil, "token", c.Request.Header.Get("token"), "OpUserID", req.OpUserID)
|
||||
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
reply, err := client.CancelMuteGroupMember(nCtx, req)
|
||||
if err != nil {
|
||||
trace_log.WriteErrorResponse(nCtx, "CancelMuteGroupMember", err)
|
||||
tracelog.WriteErrorResponse(nCtx, "CancelMuteGroupMember", err)
|
||||
return
|
||||
}
|
||||
|
||||
trace_log.SetCtxInfo(nCtx, "CancelMuteGroupMember", nil, "req", req.String(), "resp", reply.String())
|
||||
tracelog.SetCtxInfo(nCtx, "CancelMuteGroupMember", nil, "req", req.String(), "resp", reply.String())
|
||||
resp := api.CancelMuteGroupMemberResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
@@ -1269,7 +1269,7 @@ func GetGroupAbstractInfo(c *gin.Context) {
|
||||
//req api.GetGroupAbstractInfoReq
|
||||
//resp api.GetGroupAbstractInfoResp
|
||||
//)
|
||||
//nCtx := trace_log.NewCtx(c, utils.GetSelfFuncName())
|
||||
//nCtx := tracelog.NewCtx(c, utils.GetSelfFuncName())
|
||||
//if err := c.BindJSON(&req); err != nil {
|
||||
// log.NewError("0", "BindJSON failed ", err.Error())
|
||||
// c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
@@ -1301,7 +1301,7 @@ func GetGroupAbstractInfo(c *gin.Context) {
|
||||
//if err != nil {
|
||||
// //log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", err.Error())
|
||||
// //c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
// trace_log.WriteErrorResponse(nCtx, "GetGroupAbstractInfo", utils.Wrap(err, ""))
|
||||
// tracelog.WriteErrorResponse(nCtx, "GetGroupAbstractInfo", utils.Wrap(err, ""))
|
||||
// return
|
||||
//}
|
||||
//resp.GroupMemberNumber = respPb.GroupMemberNumber
|
||||
|
||||
@@ -2,7 +2,7 @@ package common
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/trace_log"
|
||||
"Open_IM/pkg/common/tracelog"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
utils2 "Open_IM/pkg/utils"
|
||||
"context"
|
||||
@@ -16,16 +16,16 @@ func ApiToRpc(c *gin.Context, apiReq, apiResp interface{}, rpcName string, rpcCl
|
||||
rpcName = utils2.GetFuncName(1)
|
||||
}
|
||||
logFuncName := fmt.Sprintf("[ApiToRpc: %s]%s", utils2.GetFuncName(1), rpcFuncName)
|
||||
ctx := trace_log.NewCtx1(c, rpcFuncName)
|
||||
ctx := tracelog.NewCtx1(c, rpcFuncName)
|
||||
defer log.ShowLog(ctx)
|
||||
if err := c.BindJSON(apiReq); err != nil {
|
||||
trace_log.WriteErrorResponse(ctx, "BindJSON", err)
|
||||
tracelog.WriteErrorResponse(ctx, "BindJSON", err)
|
||||
return
|
||||
}
|
||||
trace_log.SetCtxInfo(ctx, logFuncName, nil, "apiReq", apiReq)
|
||||
tracelog.SetCtxInfo(ctx, logFuncName, nil, "apiReq", apiReq)
|
||||
etcdConn, err := getcdv3.GetConn(ctx, rpcName)
|
||||
if err != nil {
|
||||
trace_log.WriteErrorResponse(ctx, "GetConn", err)
|
||||
tracelog.WriteErrorResponse(ctx, "GetConn", err)
|
||||
return
|
||||
}
|
||||
rpcClient := reflect.ValueOf(rpcClientFunc).Call([]reflect.Value{
|
||||
@@ -33,22 +33,22 @@ func ApiToRpc(c *gin.Context, apiReq, apiResp interface{}, rpcName string, rpcCl
|
||||
})[0].MethodByName(rpcFuncName) // rpcClient func
|
||||
rpcReqPtr := reflect.New(rpcClient.Type().In(1).Elem()) // *req
|
||||
CopyAny(apiReq, rpcReqPtr.Interface())
|
||||
trace_log.SetCtxInfo(ctx, logFuncName, nil, "opUserID", c.GetString("opUserID"), "callRpcReq", rpcString(rpcReqPtr.Elem().Interface()))
|
||||
tracelog.SetCtxInfo(ctx, logFuncName, nil, "opUserID", c.GetString("opUserID"), "callRpcReq", rpcString(rpcReqPtr.Elem().Interface()))
|
||||
respArr := rpcClient.Call([]reflect.Value{
|
||||
reflect.ValueOf(context.Context(c)), // context.Context (ctx operationID. opUserID)
|
||||
rpcReqPtr, // rpcClient apiReq
|
||||
}) // respArr => (apiResp, error)
|
||||
if !respArr[1].IsNil() { // rpcClient err != nil
|
||||
err := respArr[1].Interface().(error)
|
||||
trace_log.WriteErrorResponse(ctx, rpcFuncName, err, "callRpcResp", "error")
|
||||
tracelog.WriteErrorResponse(ctx, rpcFuncName, err, "callRpcResp", "error")
|
||||
return
|
||||
}
|
||||
rpcResp := respArr[0].Elem()
|
||||
trace_log.SetCtxInfo(ctx, rpcFuncName, nil, "callRpcResp", rpcString(rpcResp.Interface()))
|
||||
tracelog.SetCtxInfo(ctx, rpcFuncName, nil, "callRpcResp", rpcString(rpcResp.Interface()))
|
||||
if apiResp != nil {
|
||||
CopyAny(rpcResp.Interface(), apiResp)
|
||||
}
|
||||
trace_log.SetSuccess(ctx, rpcFuncName, apiResp)
|
||||
tracelog.SetSuccess(ctx, rpcFuncName, apiResp)
|
||||
}
|
||||
|
||||
func rpcString(v interface{}) string {
|
||||
|
||||
@@ -18,7 +18,7 @@ const cronTaskOperationID = "cronTaskOperationID-"
|
||||
func StartCronTask(userID, workingGroupID string) {
|
||||
log.NewPrivateLog("cron")
|
||||
log.NewInfo(utils.OperationIDGenerator(), "start cron task", "cron config", config.Config.Mongo.ChatRecordsClearTime)
|
||||
fmt.Println("cron config", config.Config.Mongo.ChatRecordsClearTime)
|
||||
fmt.Println("cron task start, config", config.Config.Mongo.ChatRecordsClearTime)
|
||||
if userID != "" {
|
||||
operationID := getCronTaskOperationID()
|
||||
StartClearMsg(operationID, []string{userID})
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
package main
|
||||
|
||||
//
|
||||
//func main() {
|
||||
// db.DB.BatchInsertChat()
|
||||
//}
|
||||
@@ -3,9 +3,11 @@ package admin_cms
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db/controller"
|
||||
"Open_IM/pkg/common/log"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/common/tracelog"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
pbAdminCMS "Open_IM/pkg/proto/admin_cms"
|
||||
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
||||
@@ -26,10 +28,13 @@ import (
|
||||
)
|
||||
|
||||
type adminCMSServer struct {
|
||||
rpcPort int
|
||||
rpcRegisterName string
|
||||
etcdSchema string
|
||||
etcdAddr []string
|
||||
rpcPort int
|
||||
rpcRegisterName string
|
||||
etcdSchema string
|
||||
etcdAddr []string
|
||||
adminCMSInterface controller.AdminCMSInterface
|
||||
groupInterface controller.GroupInterface
|
||||
userInterface controller.UserInterface
|
||||
}
|
||||
|
||||
func NewAdminCMSServer(port int) *adminCMSServer {
|
||||
@@ -82,7 +87,7 @@ func (s *adminCMSServer) Run() {
|
||||
}
|
||||
}
|
||||
log.NewInfo("", "rpcRegisterIP ", rpcRegisterIP)
|
||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10, "")
|
||||
if err != nil {
|
||||
log.NewError("0", "RegisterEtcd failed ", err.Error())
|
||||
panic(utils.Wrap(err, "register admin module rpc to etcd err"))
|
||||
@@ -95,35 +100,27 @@ func (s *adminCMSServer) Run() {
|
||||
log.NewInfo("0", "message cms rpc success")
|
||||
}
|
||||
|
||||
func (s *adminCMSServer) AdminLogin(_ context.Context, req *pbAdminCMS.AdminLoginReq) (*pbAdminCMS.AdminLoginResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbAdminCMS.AdminLoginResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
||||
func (s *adminCMSServer) AdminLogin(ctx context.Context, req *pbAdminCMS.AdminLoginReq) (*pbAdminCMS.AdminLoginResp, error) {
|
||||
resp := &pbAdminCMS.AdminLoginResp{}
|
||||
for i, adminID := range config.Config.Manager.AppManagerUid {
|
||||
if adminID == req.AdminID && config.Config.Manager.Secrets[i] == req.Secret {
|
||||
token, expTime, err := token_verify.CreateToken(adminID, constant.SingleChatType)
|
||||
token, expTime, err := token_verify.CreateToken(adminID, constant.LinuxPlatformID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "generate token failed", "adminID: ", adminID, err.Error())
|
||||
resp.CommonResp.ErrCode = constant.ErrTokenUnknown.ErrCode
|
||||
resp.CommonResp.ErrMsg = err.Error()
|
||||
return resp, nil
|
||||
log.NewError(tracelog.GetOperationID(ctx), utils.GetSelfFuncName(), "generate token failed", "adminID: ", adminID, err.Error())
|
||||
return nil, err
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "generate token success", "token: ", token, "expTime:", expTime)
|
||||
log.NewInfo(tracelog.GetOperationID(ctx), utils.GetSelfFuncName(), "generate token success", "token: ", token, "expTime:", expTime)
|
||||
resp.Token = token
|
||||
break
|
||||
}
|
||||
}
|
||||
if resp.Token == "" {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "failed")
|
||||
resp.CommonResp.ErrCode = constant.ErrTokenUnknown.ErrCode
|
||||
resp.CommonResp.ErrMsg = constant.ErrTokenMalformed.ErrMsg
|
||||
return resp, nil
|
||||
return nil, constant.ErrInternalServer
|
||||
}
|
||||
admin, err := imdb.GetUserByUserID(req.AdminID)
|
||||
admin, err := s.userInterface.Take(ctx, req.AdminID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "failed", req.AdminID, err.Error())
|
||||
resp.CommonResp.ErrCode = constant.ErrTokenUnknown.ErrCode
|
||||
resp.CommonResp.ErrMsg = err.Error()
|
||||
return resp, nil
|
||||
return nil, err
|
||||
}
|
||||
resp.UserName = admin.Nickname
|
||||
resp.FaceURL = admin.FaceURL
|
||||
@@ -149,67 +146,6 @@ func (s *adminCMSServer) GetUserToken(_ context.Context, req *pbAdminCMS.GetUser
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *adminCMSServer) AddUserRegisterAddFriendIDList(_ context.Context, req *pbAdminCMS.AddUserRegisterAddFriendIDListReq) (*pbAdminCMS.AddUserRegisterAddFriendIDListResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbAdminCMS.AddUserRegisterAddFriendIDListResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
||||
if err := imdb.AddUserRegisterAddFriendIDList(req.UserIDList...); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserIDList)
|
||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||
resp.CommonResp.ErrMsg = err.Error()
|
||||
return resp, nil
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *adminCMSServer) ReduceUserRegisterAddFriendIDList(_ context.Context, req *pbAdminCMS.ReduceUserRegisterAddFriendIDListReq) (*pbAdminCMS.ReduceUserRegisterAddFriendIDListResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbAdminCMS.ReduceUserRegisterAddFriendIDListResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
||||
if req.Operation == 0 {
|
||||
if err := imdb.ReduceUserRegisterAddFriendIDList(req.UserIDList...); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserIDList)
|
||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||
resp.CommonResp.ErrMsg = err.Error()
|
||||
return resp, nil
|
||||
}
|
||||
} else {
|
||||
if err := imdb.DeleteAllRegisterAddFriendIDList(); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserIDList)
|
||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||
resp.CommonResp.ErrMsg = err.Error()
|
||||
return resp, nil
|
||||
}
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *adminCMSServer) GetUserRegisterAddFriendIDList(_ context.Context, req *pbAdminCMS.GetUserRegisterAddFriendIDListReq) (*pbAdminCMS.GetUserRegisterAddFriendIDListResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbAdminCMS.GetUserRegisterAddFriendIDListResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
||||
userIDList, err := imdb.GetRegisterAddFriendList(req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||
resp.CommonResp.ErrMsg = err.Error()
|
||||
return resp, nil
|
||||
}
|
||||
userList, err := imdb.GetUsersByUserIDList(userIDList)
|
||||
if err != nil {
|
||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||
resp.CommonResp.ErrMsg = err.Error()
|
||||
return resp, nil
|
||||
}
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), userList, userIDList)
|
||||
resp.Pagination = &server_api_params.ResponsePagination{
|
||||
CurrentPage: req.Pagination.PageNumber,
|
||||
ShowNumber: req.Pagination.ShowNumber,
|
||||
}
|
||||
utils.CopyStructFields(&resp.UserInfoList, userList)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *adminCMSServer) GetChatLogs(_ context.Context, req *pbAdminCMS.GetChatLogsReq) (*pbAdminCMS.GetChatLogsResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetChatLogs", req.String())
|
||||
resp := &pbAdminCMS.GetChatLogsResp{CommonResp: &pbAdminCMS.CommonResp{}, Pagination: &server_api_params.ResponsePagination{}}
|
||||
@@ -302,17 +238,17 @@ func (s *adminCMSServer) GetActiveGroup(_ context.Context, req *pbAdminCMS.GetAc
|
||||
resp := &pbAdminCMS.GetActiveGroupResp{}
|
||||
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
||||
if err != nil {
|
||||
return resp, err
|
||||
return nil, err
|
||||
}
|
||||
activeGroups, err := imdb.GetActiveGroups(fromTime, toTime, 12)
|
||||
activeGroups, err := s.adminCMSInterface.GetActiveGroups(fromTime, toTime, 12)
|
||||
if err != nil {
|
||||
return resp, err
|
||||
return nil, err
|
||||
}
|
||||
for _, activeGroup := range activeGroups {
|
||||
resp.Groups = append(resp.Groups,
|
||||
&pbAdminCMS.GroupResp{
|
||||
GroupName: activeGroup.Name,
|
||||
GroupID: activeGroup.Id,
|
||||
GroupID: activeGroup.ID,
|
||||
MessageNum: int32(activeGroup.MessageNum),
|
||||
})
|
||||
}
|
||||
@@ -684,43 +620,3 @@ func (s *adminCMSServer) GetUserIDByEmailAndPhoneNumber(_ context.Context, req *
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *adminCMSServer) GenerateInvitationCode(_ context.Context, req *pbAdminCMS.GenerateInvitationCodeReq) (*pbAdminCMS.GenerateInvitationCodeResp, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *adminCMSServer) GetInvitationCodes(_ context.Context, req *pbAdminCMS.GetInvitationCodesReq) (*pbAdminCMS.GetInvitationCodesResp, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *adminCMSServer) QueryIPRegister(_ context.Context, req *pbAdminCMS.QueryIPRegisterReq) (*pbAdminCMS.QueryIPRegisterResp, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *adminCMSServer) AddIPLimit(_ context.Context, req *pbAdminCMS.AddIPLimitReq) (*pbAdminCMS.AddIPLimitResp, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *adminCMSServer) RemoveIPLimit(_ context.Context, req *pbAdminCMS.RemoveIPLimitReq) (*pbAdminCMS.RemoveIPLimitResp, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *adminCMSServer) QueryUserIDIPLimitLogin(_ context.Context, req *pbAdminCMS.QueryUserIDIPLimitLoginReq) (*pbAdminCMS.QueryUserIDIPLimitLoginResp, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *adminCMSServer) AddUserIPLimitLogin(_ context.Context, req *pbAdminCMS.AddUserIPLimitLoginReq) (*pbAdminCMS.AddUserIPLimitLoginResp, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *adminCMSServer) RemoveUserIPLimit(_ context.Context, req *pbAdminCMS.RemoveUserIPLimitReq) (*pbAdminCMS.RemoveUserIPLimitResp, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *adminCMSServer) GetClientInitConfig(_ context.Context, req *pbAdminCMS.GetClientInitConfigReq) (*pbAdminCMS.GetClientInitConfigResp, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *adminCMSServer) SetClientInitConfig(_ context.Context, req *pbAdminCMS.SetClientInitConfigReq) (*pbAdminCMS.SetClientInitConfigResp, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/common/tools"
|
||||
"Open_IM/pkg/common/trace_log"
|
||||
"Open_IM/pkg/common/tracelog"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
sdkws "Open_IM/pkg/proto/sdk_ws"
|
||||
@@ -255,7 +255,7 @@ func (s *friendServer) AddFriendResponse(ctx context.Context, req *pbFriend.AddF
|
||||
} else if req.HandleResult == constant.FriendResponseRefuse {
|
||||
chat.FriendApplicationRejectedNotification(req)
|
||||
} else {
|
||||
trace_log.SetCtxInfo(ctx, utils.GetSelfFuncName(), nil, "handleResult", req.HandleResult)
|
||||
tracelog.SetCtxInfo(ctx, utils.GetSelfFuncName(), nil, "handleResult", req.HandleResult)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
relation "Open_IM/pkg/common/db/mysql"
|
||||
"Open_IM/pkg/common/http"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/trace_log"
|
||||
"Open_IM/pkg/common/tracelog"
|
||||
pbGroup "Open_IM/pkg/proto/group"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
|
||||
func callbackBeforeCreateGroup(ctx context.Context, req *pbGroup.CreateGroupReq) (err error) {
|
||||
defer func() {
|
||||
trace_log.SetCtxInfo(ctx, utils.GetFuncName(1), err, "req", req)
|
||||
tracelog.SetCtxInfo(ctx, utils.GetFuncName(1), err, "req", req)
|
||||
}()
|
||||
if !config.Config.Callback.CallbackBeforeCreateGroup.Enable {
|
||||
return nil
|
||||
@@ -79,7 +79,7 @@ func callbackBeforeCreateGroup(ctx context.Context, req *pbGroup.CreateGroupReq)
|
||||
|
||||
func CallbackBeforeMemberJoinGroup(ctx context.Context, operationID string, groupMember *relation.GroupMember, groupEx string) (err error) {
|
||||
defer func() {
|
||||
trace_log.SetCtxInfo(ctx, utils.GetFuncName(1), err, "groupMember", *groupMember, "groupEx", groupEx)
|
||||
tracelog.SetCtxInfo(ctx, utils.GetFuncName(1), err, "groupMember", *groupMember, "groupEx", groupEx)
|
||||
}()
|
||||
callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
|
||||
if !config.Config.Callback.CallbackBeforeMemberJoinGroup.Enable {
|
||||
@@ -121,7 +121,7 @@ func CallbackBeforeMemberJoinGroup(ctx context.Context, operationID string, grou
|
||||
|
||||
func CallbackBeforeSetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGroupMemberInfoReq) (err error) {
|
||||
defer func() {
|
||||
trace_log.SetCtxInfo(ctx, utils.GetFuncName(1), err, "req", *req)
|
||||
tracelog.SetCtxInfo(ctx, utils.GetFuncName(1), err, "req", *req)
|
||||
}()
|
||||
callbackResp := cbApi.CommonCallbackResp{OperationID: req.OperationID}
|
||||
if !config.Config.Callback.CallbackBeforeSetGroupMemberInfo.Enable {
|
||||
|
||||
+21
-21
@@ -14,7 +14,7 @@ import (
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/common/tools"
|
||||
"Open_IM/pkg/common/trace_log"
|
||||
"Open_IM/pkg/common/tracelog"
|
||||
|
||||
cp "Open_IM/internal/utils"
|
||||
"Open_IM/pkg/getcdv3"
|
||||
@@ -466,23 +466,23 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
||||
kickedInfo, err := rocksCache.GetGroupMemberInfoFromCache(ctx, req.GroupID, v)
|
||||
if err != nil {
|
||||
resp.Id2ResultList = append(resp.Id2ResultList, &pbGroup.Id2Result{UserID: v, Result: -1})
|
||||
trace_log.SetCtxInfo(ctx, "GetGroupMemberInfoFromCache", err, "groupID", req.GroupID, "userID", v)
|
||||
tracelog.SetCtxInfo(ctx, "GetGroupMemberInfoFromCache", err, "groupID", req.GroupID, "userID", v)
|
||||
continue
|
||||
}
|
||||
|
||||
if kickedInfo.RoleLevel == constant.GroupAdmin && opFlag == 3 {
|
||||
resp.Id2ResultList = append(resp.Id2ResultList, &pbGroup.Id2Result{UserID: v, Result: -1})
|
||||
trace_log.SetCtxInfo(ctx, "", nil, "msg", "is constant.GroupAdmin, can't kicked", "groupID", req.GroupID, "userID", v)
|
||||
tracelog.SetCtxInfo(ctx, "", nil, "msg", "is constant.GroupAdmin, can't kicked", "groupID", req.GroupID, "userID", v)
|
||||
continue
|
||||
}
|
||||
if kickedInfo.RoleLevel == constant.GroupOwner && opFlag != 1 {
|
||||
resp.Id2ResultList = append(resp.Id2ResultList, &pbGroup.Id2Result{UserID: v, Result: -1})
|
||||
trace_log.SetCtxInfo(ctx, "", nil, "msg", "is constant.GroupOwner, can't kicked", "groupID", req.GroupID, "userID", v)
|
||||
tracelog.SetCtxInfo(ctx, "", nil, "msg", "is constant.GroupOwner, can't kicked", "groupID", req.GroupID, "userID", v)
|
||||
continue
|
||||
}
|
||||
|
||||
err = relation.DeleteGroupMemberByGroupIDAndUserID(req.GroupID, v)
|
||||
trace_log.SetCtxInfo(ctx, "RemoveGroupMember", err, "groupID", req.GroupID, "userID", v)
|
||||
tracelog.SetCtxInfo(ctx, "RemoveGroupMember", err, "groupID", req.GroupID, "userID", v)
|
||||
if err != nil {
|
||||
log.NewError(tools.OperationID(ctx), "RemoveGroupMember failed ", err.Error(), req.GroupID, v)
|
||||
resp.Id2ResultList = append(resp.Id2ResultList, &pbGroup.Id2Result{UserID: v, Result: -1})
|
||||
@@ -507,7 +507,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
||||
}
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.SetConversation(context.Background(), &reqPb)
|
||||
trace_log.SetCtxInfo(ctx, "SetConversation", err, "req", &reqPb, "resp", respPb)
|
||||
tracelog.SetCtxInfo(ctx, "SetConversation", err, "req", &reqPb, "resp", respPb)
|
||||
}
|
||||
} else {
|
||||
okUserIDList = req.KickedUserIDList
|
||||
@@ -519,14 +519,14 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
||||
if groupInfo.GroupType != constant.SuperGroup {
|
||||
for _, userID := range okUserIDList {
|
||||
if err := rocksCache.DelGroupMemberInfoFromCache(ctx, req.GroupID, userID); err != nil {
|
||||
trace_log.SetCtxInfo(ctx, "DelGroupMemberInfoFromCache", err, "groupID", req.GroupID, "userID", userID)
|
||||
tracelog.SetCtxInfo(ctx, "DelGroupMemberInfoFromCache", err, "groupID", req.GroupID, "userID", userID)
|
||||
}
|
||||
}
|
||||
chat.MemberKickedNotification(req, okUserIDList)
|
||||
} else {
|
||||
for _, userID := range okUserIDList {
|
||||
if err = rocksCache.DelJoinedSuperGroupIDListFromCache(ctx, userID); err != nil {
|
||||
trace_log.SetCtxInfo(ctx, "DelGroupMemberInfoFromCache", err, "userID", userID)
|
||||
tracelog.SetCtxInfo(ctx, "DelGroupMemberInfoFromCache", err, "userID", userID)
|
||||
}
|
||||
}
|
||||
go func() {
|
||||
@@ -584,7 +584,7 @@ func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup.
|
||||
return nil, err
|
||||
}
|
||||
var errResult error
|
||||
trace_log.SetCtxInfo(ctx, "GetRecvGroupApplicationList", nil, " FromUserID: ", req.FromUserID, "GroupApplicationList: ", reply)
|
||||
tracelog.SetCtxInfo(ctx, "GetRecvGroupApplicationList", nil, " FromUserID: ", req.FromUserID, "GroupApplicationList: ", reply)
|
||||
for _, v := range reply {
|
||||
node := open_im_sdk.GroupRequest{UserInfo: &open_im_sdk.PublicUserInfo{}, GroupInfo: &open_im_sdk.GroupInfo{}}
|
||||
err := FillGroupInfoByGroupID(tools.OperationID(ctx), v.GroupID, node.GroupInfo)
|
||||
@@ -594,7 +594,7 @@ func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup.
|
||||
}
|
||||
continue
|
||||
}
|
||||
trace_log.SetCtxInfo(ctx, "FillGroupInfoByGroupID ", nil, " groupID: ", v.GroupID, " groupInfo: ", node.GroupInfo)
|
||||
tracelog.SetCtxInfo(ctx, "FillGroupInfoByGroupID ", nil, " groupID: ", v.GroupID, " groupInfo: ", node.GroupInfo)
|
||||
err = FillPublicUserInfoByUserID(tools.OperationID(ctx), v.UserID, node.UserInfo)
|
||||
if err != nil {
|
||||
errResult = err
|
||||
@@ -606,7 +606,7 @@ func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup.
|
||||
if errResult != nil && len(resp.GroupRequestList) == 0 {
|
||||
return nil, err
|
||||
}
|
||||
trace_log.SetRpcRespInfo(ctx, utils.GetSelfFuncName(), resp.String())
|
||||
tracelog.SetRpcRespInfo(ctx, utils.GetSelfFuncName(), resp.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@@ -629,7 +629,7 @@ func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbGroup.GetGroupsI
|
||||
|
||||
func CheckPermission(ctx context.Context, groupID string, userID string) (err error) {
|
||||
defer func() {
|
||||
trace_log.SetCtxInfo(ctx, utils.GetSelfFuncName(), err, "groupID", groupID, "userID", userID)
|
||||
tracelog.SetCtxInfo(ctx, utils.GetSelfFuncName(), err, "groupID", groupID, "userID", userID)
|
||||
}()
|
||||
if !token_verify.IsManagerUserID(userID) && !relation.IsGroupOwnerAdmin(groupID, userID) {
|
||||
return utils.Wrap(constant.ErrNoPermission, utils.GetSelfFuncName())
|
||||
@@ -749,7 +749,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
|
||||
}
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.SetConversation(context.Background(), &reqPb)
|
||||
trace_log.SetCtxInfo(ctx, "SetConversation", err, "req", reqPb, "resp", respPb)
|
||||
tracelog.SetCtxInfo(ctx, "SetConversation", err, "req", reqPb, "resp", respPb)
|
||||
chat.MemberEnterDirectlyNotification(req.GroupID, tools.OpUserID(ctx), tools.OperationID(ctx))
|
||||
return resp, nil
|
||||
} else {
|
||||
@@ -917,7 +917,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
||||
}
|
||||
nClient := pbConversation.NewConversationClient(nEtcdConn)
|
||||
conversationReply, err := nClient.ModifyConversationField(context.Background(), &conversationReq)
|
||||
trace_log.SetCtxInfo(ctx, "ModifyConversationField", err, "req", &conversationReq, "resp", conversationReply)
|
||||
tracelog.SetCtxInfo(ctx, "ModifyConversationField", err, "req", &conversationReq, "resp", conversationReply)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
@@ -990,14 +990,14 @@ func (s *groupServer) GetGroups(ctx context.Context, req *pbGroup.GetGroupsReq)
|
||||
} else {
|
||||
groups, count, err := relation.GetGroupsByName(req.GroupName, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
if err != nil {
|
||||
trace_log.SetCtxInfo(ctx, "GetGroupsByName", err, "GroupName", req.GroupName, "PageNumber", req.Pagination.PageNumber, "ShowNumber", req.Pagination.ShowNumber)
|
||||
tracelog.SetCtxInfo(ctx, "GetGroupsByName", err, "GroupName", req.GroupName, "PageNumber", req.Pagination.PageNumber, "ShowNumber", req.Pagination.ShowNumber)
|
||||
}
|
||||
for _, v := range groups {
|
||||
group := &pbGroup.CMSGroup{GroupInfo: &open_im_sdk.GroupInfo{}}
|
||||
utils.CopyStructFields(group.GroupInfo, v)
|
||||
groupMember, err := relation.GetGroupOwnerInfoByGroupID(v.GroupID)
|
||||
if err != nil {
|
||||
trace_log.SetCtxInfo(ctx, "GetGroupOwnerInfoByGroupID", err, "GroupID", v.GroupID)
|
||||
tracelog.SetCtxInfo(ctx, "GetGroupOwnerInfoByGroupID", err, "GroupID", v.GroupID)
|
||||
continue
|
||||
}
|
||||
group.GroupInfo.CreateTime = uint32(v.CreateTime.Unix())
|
||||
@@ -1046,12 +1046,12 @@ func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbGrou
|
||||
node := open_im_sdk.GroupRequest{UserInfo: &open_im_sdk.PublicUserInfo{}, GroupInfo: &open_im_sdk.GroupInfo{}}
|
||||
group, err := relation.GetGroupInfoByGroupID(groupReq.GroupID)
|
||||
if err != nil {
|
||||
trace_log.SetCtxInfo(ctx, "GetGroupInfoByGroupID", err, "GroupID", groupReq.GroupID)
|
||||
tracelog.SetCtxInfo(ctx, "GetGroupInfoByGroupID", err, "GroupID", groupReq.GroupID)
|
||||
continue
|
||||
}
|
||||
user, err := relation.GetUserByUserID(groupReq.UserID)
|
||||
if err != nil {
|
||||
trace_log.SetCtxInfo(ctx, "GetUserByUserID", err, "UserID", groupReq.UserID)
|
||||
tracelog.SetCtxInfo(ctx, "GetUserByUserID", err, "UserID", groupReq.UserID)
|
||||
continue
|
||||
}
|
||||
cp.GroupRequestDBCopyOpenIM(&node, &groupReq)
|
||||
@@ -1087,7 +1087,7 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGrou
|
||||
if groupInfo.GroupType != constant.SuperGroup {
|
||||
memberList, err := relation.GetGroupMemberListByGroupID(req.GroupID)
|
||||
if err != nil {
|
||||
trace_log.SetCtxInfo(ctx, "GetGroupMemberListByGroupID", err, "groupID", req.GroupID)
|
||||
tracelog.SetCtxInfo(ctx, "GetGroupMemberListByGroupID", err, "groupID", req.GroupID)
|
||||
}
|
||||
//modify quitter conversation info
|
||||
var reqPb pbUser.SetConversationReq
|
||||
@@ -1103,7 +1103,7 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGrou
|
||||
etcdConn, err := getcdv3.GetConn(ctx, config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.SetConversation(context.Background(), &reqPb)
|
||||
trace_log.SetCtxInfo(ctx, "SetConversation", err, "req", &reqPb, "resp", respPb)
|
||||
tracelog.SetCtxInfo(ctx, "SetConversation", err, "req", &reqPb, "resp", respPb)
|
||||
}
|
||||
err = relation.DeleteGroupMemberByGroupID(req.GroupID)
|
||||
if err != nil {
|
||||
@@ -1366,7 +1366,7 @@ func (s *groupServer) GetGroupAbstractInfo(ctx context.Context, req *pbGroup.Get
|
||||
}
|
||||
|
||||
func (s *groupServer) DelGroupAndUserCache(ctx context.Context, groupID string, userIDList []string) error {
|
||||
operationID := trace_log.GetOperationID(ctx)
|
||||
operationID := tracelog.GetOperationID(ctx)
|
||||
if groupID != "" {
|
||||
etcdConn, err := getcdv3.GetConn(ctx, config.Config.RpcRegisterName.OpenImCacheName)
|
||||
if err != nil {
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
package utils
|
||||
Reference in New Issue
Block a user