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/msg_status.go

47 lines
1.5 KiB

2 years ago
package msg
import (
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db"
"Open_IM/pkg/common/log"
pbMsg "Open_IM/pkg/proto/msg"
"Open_IM/pkg/utils"
"context"
2 years ago
2 years ago
goRedis "github.com/go-redis/redis/v8"
)
2 years ago
func (rpc *rpcChat) SetSendMsgStatus(_ context.Context, req *pbMsg.SetSendMsgStatusReq) (resp *pbMsg.SetSendMsgStatusResp, err error) {
resp = &pbMsg.SetSendMsgStatusResp{}
2 years ago
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
2 years ago
if err := db.DB.SetSendMsgStatus(req.Status, req.OperationID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
2 years ago
resp.ErrCode = constant.ErrDB.ErrCode
resp.ErrMsg = err.Error()
return resp, nil
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String())
return resp, nil
}
2 years ago
func (rpc *rpcChat) GetSendMsgStatus(_ context.Context, req *pbMsg.GetSendMsgStatusReq) (resp *pbMsg.GetSendMsgStatusResp, err error) {
2 years ago
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
2 years ago
resp = &pbMsg.GetSendMsgStatusResp{}
2 years ago
status, err := db.DB.GetSendMsgStatus(req.OperationID)
if err != nil {
resp.Status = constant.MsgStatusNotExist
2 years ago
if err == goRedis.Nil {
2 years ago
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.OperationID, "not exist")
2 years ago
return resp, nil
2 years ago
} else {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
resp.ErrMsg = err.Error()
resp.ErrCode = constant.ErrDB.ErrCode
2 years ago
return resp, nil
2 years ago
}
}
2 years ago
resp.Status = int32(status)
2 years ago
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String())
return resp, nil
}