Skip to content

Commit

Permalink
refactor: fix error handling in SendMessage function (#704)
Browse files Browse the repository at this point in the history
  • Loading branch information
mo3et authored Sep 18, 2024
1 parent c8dac40 commit ba04362
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions internal/conversation_msg/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ func (c *Conversation) SendMessage(ctx context.Context, s *sdk_struct.MsgStruct,
if err != nil {
c.updateMsgStatusAndTriggerConversation(ctx, s.ClientMsgID, "", s.CreateTime, constant.MsgStatusSendFailed, s, lc, isOnlineOnly)
putErrs = err
return
}
if res != nil {
s.VideoElem.VideoURL = res.URL
Expand Down
3 changes: 3 additions & 0 deletions pkg/constant/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ const (
CustomMsgNotTriggerConversation = 119
CustomMsgOnlineOnly = 120

NotificationBegin = 1000

FriendNotificationBegin = 1200

FriendApplicationApprovedNotification = 1201 //add_friend_response
Expand Down Expand Up @@ -124,6 +126,7 @@ const (

HasReadReceipt = 2200

NotificationEnd = 5000
////////////////////////////////////////

//MsgFrom
Expand Down
3 changes: 1 addition & 2 deletions pkg/db/conversation_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ func (d *DataBase) GetConversationListSplitDB(ctx context.Context, offset, count
d.mRWMutex.RLock()
defer d.mRWMutex.RUnlock()
var conversationList []*model_struct.LocalConversation
return conversationList, errs.WrapMsg(d.conn.WithContext(ctx).Where("latest_msg_send_time > ?", 0).Order("case when is_pinned=1 then 0 else 1 end,max(latest_msg_send_time,draft_text_time) DESC").Offset(offset).Limit(count).Find(&conversationList).Error,
"GetFriendList failed")
return conversationList, errs.Wrap(d.conn.WithContext(ctx).Where("latest_msg_send_time > ?", 0).Order("case when is_pinned=1 then 0 else 1 end,max(latest_msg_send_time,draft_text_time) DESC").Offset(offset).Limit(count).Find(&conversationList).Error)
}

func (d *DataBase) BatchInsertConversationList(ctx context.Context, conversationList []*model_struct.LocalConversation) error {
Expand Down

0 comments on commit ba04362

Please sign in to comment.