You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Open-IM-Server/internal/rpc/msg/chat.go

39 lines
1.5 KiB

package msg
import (
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
"Open_IM/pkg/proto/chat"
"Open_IM/pkg/utils"
"context"
)
func (rpc *rpcChat) ClearMsg(_ context.Context, req *pbChat.ClearMsgReq) (*pbChat.ClearMsgResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc req: ", req.String())
if req.OpUserID != req.UserID && !token_verify.IsManagerUserID(req.UserID) {
errMsg := "No permission" + req.OpUserID + req.UserID
log.Error(req.OperationID, errMsg)
return &pbChat.ClearMsgResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}, nil
}
log.Debug(req.OperationID, "CleanUpOneUserAllMsgFromRedis args", req.UserID)
3 years ago
err := db.DB.CleanUpOneUserAllMsgFromRedis(req.UserID, req.OperationID)
if err != nil {
errMsg := "CleanUpOneUserAllMsgFromRedis failed " + err.Error() + req.OperationID + req.UserID
log.Error(req.OperationID, errMsg)
return &pbChat.ClearMsgResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}, nil
}
log.Debug(req.OperationID, "CleanUpUserMsgFromMongo args", req.UserID)
3 years ago
err = db.DB.CleanUpUserMsgFromMongo(req.UserID, req.OperationID)
if err != nil {
errMsg := "CleanUpUserMsgFromMongo failed " + err.Error() + req.OperationID + req.UserID
log.Error(req.OperationID, errMsg)
return &pbChat.ClearMsgResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}, nil
}
resp := pbChat.ClearMsgResp{ErrCode: 0}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
return &resp, nil
}