mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-02 16:15:59 +08:00
msg status
This commit is contained in:
@@ -1,46 +1,24 @@
|
||||
package msg
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/tracelog"
|
||||
pbMsg "Open_IM/pkg/proto/msg"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
|
||||
goRedis "github.com/go-redis/redis/v8"
|
||||
)
|
||||
|
||||
func (rpc *msgServer) SetSendMsgStatus(_ context.Context, req *pbMsg.SetSendMsgStatusReq) (resp *pbMsg.SetSendMsgStatusResp, err error) {
|
||||
resp = &pbMsg.SetSendMsgStatusResp{}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
||||
if err := db.DB.SetSendMsgStatus(req.Status, req.OperationID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
resp.ErrCode = constant.ErrDatabase.ErrCode
|
||||
resp.ErrMsg = err.Error()
|
||||
return resp, nil
|
||||
func (s *msgServer) SetSendMsgStatus(ctx context.Context, req *pbMsg.SetSendMsgStatusReq) (*pbMsg.SetSendMsgStatusResp, error) {
|
||||
resp := &pbMsg.SetSendMsgStatusResp{}
|
||||
if err := s.MsgInterface.SetSendMsgStatus(ctx, tracelog.GetOperationID(ctx), req.Status); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (rpc *msgServer) GetSendMsgStatus(_ context.Context, req *pbMsg.GetSendMsgStatusReq) (resp *pbMsg.GetSendMsgStatusResp, err error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
||||
func (s *msgServer) GetSendMsgStatus(ctx context.Context, req *pbMsg.GetSendMsgStatusReq) (resp *pbMsg.GetSendMsgStatusResp, err error) {
|
||||
resp = &pbMsg.GetSendMsgStatusResp{}
|
||||
status, err := db.DB.GetSendMsgStatus(req.OperationID)
|
||||
resp.Status, err = s.MsgInterface.GetSendMsgStatus(ctx, tracelog.GetOperationID(ctx))
|
||||
if err != nil {
|
||||
resp.Status = constant.MsgStatusNotExist
|
||||
if err == goRedis.Nil {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.OperationID, "not exist")
|
||||
return resp, nil
|
||||
} else {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
resp.ErrMsg = err.Error()
|
||||
resp.ErrCode = constant.ErrDB.ErrCode
|
||||
return resp, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
resp.Status = int32(status)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user