mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-03 02:42:19 +08:00
fix: fix openim api err code
This commit is contained in:
parent
97285bf4d8
commit
77628bc454
@ -210,7 +210,6 @@ func (m *MessageApi) SendMessage(c *gin.Context) {
|
|||||||
sendMsgReq, err := m.getSendMsgReq(c, req.SendMsg)
|
sendMsgReq, err := m.getSendMsgReq(c, req.SendMsg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Log and respond with an error if preparation fails.
|
// Log and respond with an error if preparation fails.
|
||||||
log.ZError(c, "decodeData failed", err)
|
|
||||||
apiresp.GinError(c, err)
|
apiresp.GinError(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -226,7 +225,6 @@ func (m *MessageApi) SendMessage(c *gin.Context) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
// Set the status to failed and respond with an error if sending fails.
|
// Set the status to failed and respond with an error if sending fails.
|
||||||
status = constant.MsgSendFailed
|
status = constant.MsgSendFailed
|
||||||
log.ZError(c, "send message err", err)
|
|
||||||
apiresp.GinError(c, err)
|
apiresp.GinError(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -240,7 +238,8 @@ func (m *MessageApi) SendMessage(c *gin.Context) {
|
|||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Log the error if updating the status fails.
|
// Log the error if updating the status fails.
|
||||||
log.ZError(c, "SetSendMsgStatus failed", err)
|
apiresp.GinError(c, err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Respond with a success message and the response payload.
|
// Respond with a success message and the response payload.
|
||||||
@ -299,7 +298,6 @@ func (m *MessageApi) BatchSendMsg(c *gin.Context) {
|
|||||||
resp apistruct.BatchSendMsgResp
|
resp apistruct.BatchSendMsgResp
|
||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.ZError(c, "BatchSendMsg BindJSON failed", err)
|
|
||||||
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
|
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -317,7 +315,6 @@ func (m *MessageApi) BatchSendMsg(c *gin.Context) {
|
|||||||
for {
|
for {
|
||||||
recvIDsPart, err := m.userRpcClient.GetAllUserIDs(c, int32(pageNumber), int32(showNumber))
|
recvIDsPart, err := m.userRpcClient.GetAllUserIDs(c, int32(pageNumber), int32(showNumber))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(c, "GetAllUserIDs failed", err)
|
|
||||||
apiresp.GinError(c, err)
|
apiresp.GinError(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -333,7 +330,6 @@ func (m *MessageApi) BatchSendMsg(c *gin.Context) {
|
|||||||
log.ZDebug(c, "BatchSendMsg nums", "nums ", len(recvIDs))
|
log.ZDebug(c, "BatchSendMsg nums", "nums ", len(recvIDs))
|
||||||
sendMsgReq, err := m.getSendMsgReq(c, req.SendMsg)
|
sendMsgReq, err := m.getSendMsgReq(c, req.SendMsg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(c, "decodeData failed", err)
|
|
||||||
apiresp.GinError(c, err)
|
apiresp.GinError(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -278,7 +278,6 @@ func GinParseToken(rdb redis.UniversalClient) gin.HandlerFunc {
|
|||||||
// handleGinError logs and returns an error response through Gin context.
|
// handleGinError logs and returns an error response through Gin context.
|
||||||
func handleGinError(c *gin.Context, logMessage string, errType errs.CodeError, detail string) {
|
func handleGinError(c *gin.Context, logMessage string, errType errs.CodeError, detail string) {
|
||||||
wrappedErr := errType.Wrap(detail)
|
wrappedErr := errType.Wrap(detail)
|
||||||
log.ZInfo(c, logMessage, wrappedErr)
|
|
||||||
apiresp.GinError(c, wrappedErr)
|
apiresp.GinError(c, wrappedErr)
|
||||||
c.Abort()
|
c.Abort()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -83,7 +83,7 @@ func (u *UserApi) GetUsersOnlineStatus(c *gin.Context) {
|
|||||||
msgClient := msggateway.NewMsgGatewayClient(conn)
|
msgClient := msggateway.NewMsgGatewayClient(conn)
|
||||||
reply, err := msgClient.GetUsersOnlineStatus(c, &req)
|
reply, err := msgClient.GetUsersOnlineStatus(c, &req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZInfo(c, "GetUsersOnlineStatus rpc error", err)
|
log.ZDebug(c, "GetUsersOnlineStatus rpc error", err)
|
||||||
if apiresp.ParseError(err).ErrCode == errs.NoPermissionError {
|
if apiresp.ParseError(err).ErrCode == errs.NoPermissionError {
|
||||||
apiresp.GinError(c, errs.Wrap(err))
|
apiresp.GinError(c, errs.Wrap(err))
|
||||||
return
|
return
|
||||||
|
|||||||
@ -32,7 +32,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func StartTask() error {
|
func StartTask() error {
|
||||||
fmt.Println("cron task start, config", config.Config.ChatRecordsClearTime)
|
fmt.Println("Cron task start, config:", config.Config.ChatRecordsClearTime)
|
||||||
|
|
||||||
msgTool, err := InitMsgTool()
|
msgTool, err := InitMsgTool()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -48,16 +48,16 @@ func StartTask() error {
|
|||||||
|
|
||||||
// register cron tasks
|
// register cron tasks
|
||||||
var crontab = cron.New()
|
var crontab = cron.New()
|
||||||
fmt.Println("start chatRecordsClearTime cron task", "cron config", config.Config.ChatRecordsClearTime)
|
fmt.Printf("Start chatRecordsClearTime cron task, cron config: %s\n", config.Config.ChatRecordsClearTime)
|
||||||
_, err = crontab.AddFunc(config.Config.ChatRecordsClearTime, cronWrapFunc(rdb, "cron_clear_msg_and_fix_seq", msgTool.AllConversationClearMsgAndFixSeq))
|
_, err = crontab.AddFunc(config.Config.ChatRecordsClearTime, cronWrapFunc(rdb, "cron_clear_msg_and_fix_seq", msgTool.AllConversationClearMsgAndFixSeq))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errs.Wrap(err)
|
return errs.Wrap(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("start msgDestruct cron task", "cron config", config.Config.MsgDestructTime)
|
fmt.Printf("Start msgDestruct cron task, cron config: %s\n", config.Config.MsgDestructTime)
|
||||||
_, err = crontab.AddFunc(config.Config.MsgDestructTime, cronWrapFunc(rdb, "cron_conversations_destruct_msgs", msgTool.ConversationsDestructMsgs))
|
_, err = crontab.AddFunc(config.Config.MsgDestructTime, cronWrapFunc(rdb, "cron_conversations_destruct_msgs", msgTool.ConversationsDestructMsgs))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errs.Wrap(err)
|
return errs.Wrap(err, "cron_conversations_destruct_msgs")
|
||||||
}
|
}
|
||||||
|
|
||||||
// start crontab
|
// start crontab
|
||||||
|
|||||||
@ -197,7 +197,8 @@ func (c *MsgTool) checkMaxSeqWithMongo(ctx context.Context, conversationID strin
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if math.Abs(float64(maxSeqMongo-maxSeqCache)) > 10 {
|
if math.Abs(float64(maxSeqMongo-maxSeqCache)) > 10 {
|
||||||
log.ZError(ctx, "cache max seq and mongo max seq is diff > 10", nil, "maxSeqMongo", maxSeqMongo, "minSeqMongo", minSeqMongo, "maxSeqCache", maxSeqCache, "conversationID", conversationID)
|
err = fmt.Errorf("cache max seq and mongo max seq is diff > 10, maxSeqMongo:%d,minSeqMongo:%d,maxSeqCache:%d,conversationID:%s", maxSeqMongo, minSeqMongo, maxSeqCache, conversationID)
|
||||||
|
return errs.Wrap(err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -219,7 +220,6 @@ func (c *MsgTool) checkMaxSeq(ctx context.Context, conversationID string) error
|
|||||||
func (c *MsgTool) FixAllSeq(ctx context.Context) error {
|
func (c *MsgTool) FixAllSeq(ctx context.Context) error {
|
||||||
conversationIDs, err := c.conversationDatabase.GetAllConversationIDs(ctx)
|
conversationIDs, err := c.conversationDatabase.GetAllConversationIDs(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(ctx, "GetAllConversationIDs failed", err)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, conversationID := range conversationIDs {
|
for _, conversationID := range conversationIDs {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user