Skip to content

Commit

Permalink
Merge pull request #2889 from openimsdk/cherry-pick-cbade46
Browse files Browse the repository at this point in the history
deps: Merge  #2881 #2883 #2884 #2885 PRs into release-v3.8.2
  • Loading branch information
mo3et authored Nov 25, 2024
2 parents 687b2eb + 7d51797 commit c328d39
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 19 deletions.
23 changes: 16 additions & 7 deletions internal/rpc/msg/as_read.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,23 @@ func (m *msgServer) MarkConversationAsRead(ctx context.Context, req *msg.MarkCon
req.UserID, seqs, hasReadSeq)
}

reqCall := &cbapi.CallbackGroupMsgReadReq{
SendID: conversation.OwnerUserID,
ReceiveID: req.UserID,
UnreadMsgNum: req.HasReadSeq,
ContentType: int64(conversation.ConversationType),
if conversation.ConversationType == constant.SingleChatType {
reqCall := &cbapi.CallbackSingleMsgReadReq{
ConversationID: conversation.ConversationID,
UserID: conversation.OwnerUserID,
Seqs: req.Seqs,
ContentType: conversation.ConversationType,
}
m.webhookAfterSingleMsgRead(ctx, &m.config.WebhooksConfig.AfterSingleMsgRead, reqCall)
} else if conversation.ConversationType == constant.ReadGroupChatType {
reqCall := &cbapi.CallbackGroupMsgReadReq{
SendID: conversation.OwnerUserID,
ReceiveID: req.UserID,
UnreadMsgNum: req.HasReadSeq,
ContentType: int64(conversation.ConversationType),
}
m.webhookAfterGroupMsgRead(ctx, &m.config.WebhooksConfig.AfterGroupMsgRead, reqCall)
}

m.webhookAfterGroupMsgRead(ctx, &m.config.WebhooksConfig.AfterGroupMsgRead, reqCall)
return &msg.MarkConversationAsReadResp{}, nil
}

Expand Down
3 changes: 0 additions & 3 deletions internal/rpc/msg/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,6 @@ func (m *msgServer) sendMsgSingleChat(ctx context.Context, req *pbmsg.SendMsgReq
prommetrics.SingleChatMsgProcessFailedCounter.Inc()
return nil, nil
} else {
if err = m.webhookBeforeSendSingleMsg(ctx, &m.config.WebhooksConfig.BeforeSendSingleMsg, req); err != nil {
return nil, err
}
if err := m.webhookBeforeMsgModify(ctx, &m.config.WebhooksConfig.BeforeMsgModify, req); err != nil {
return nil, err
}
Expand Down
3 changes: 3 additions & 0 deletions internal/rpc/msg/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ func (m *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgRe
data.MsgData.ContentType >= constant.NotificationBegin {
return nil
}
if err := m.webhookBeforeSendSingleMsg(ctx, &m.config.WebhooksConfig.BeforeSendSingleMsg, data); err != nil {
return err
}
black, err := m.FriendLocalCache.IsBlack(ctx, data.MsgData.SendID, data.MsgData.RecvID)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/storage/cache/redis/conversation.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const (
func NewConversationRedis(rdb redis.UniversalClient, localCache *config.LocalCache, opts *rockscache.Options, db database.Conversation) cache.ConversationCache {
batchHandler := NewBatchDeleterRedis(rdb, opts, []string{localCache.Conversation.Topic})
c := localCache.Conversation
log.ZDebug(context.Background(), "black local cache init", "Topic", c.Topic, "SlotNum", c.SlotNum, "SlotSize", c.SlotSize, "enable", c.Enable())
log.ZDebug(context.Background(), "conversation local cache init", "Topic", c.Topic, "SlotNum", c.SlotNum, "SlotSize", c.SlotSize, "enable", c.Enable())
return &ConversationRedisCache{
BatchDeleter: batchHandler,
rcClient: rockscache.NewClient(rdb, *opts),
Expand Down
16 changes: 8 additions & 8 deletions pkg/common/storage/controller/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,10 +444,10 @@ func (db *commonMsgDatabase) GetMsgBySeqsRange(ctx context.Context, userID strin
}
successMsgs = append(mongoMsgs, successMsgs...)

_, err = db.msg.SetMessagesToCache(ctx, conversationID, mongoMsgs)
if err != nil {
return 0, 0, nil, err
}
//_, err = db.msg.SetMessagesToCache(ctx, conversationID, mongoMsgs)
//if err != nil {
// return 0, 0, nil, err
//}
}

return minSeq, maxSeq, successMsgs, nil
Expand Down Expand Up @@ -506,10 +506,10 @@ func (db *commonMsgDatabase) GetMsgBySeqs(ctx context.Context, userID string, co

successMsgs = append(successMsgs, mongoMsgs...)

_, err = db.msg.SetMessagesToCache(ctx, conversationID, mongoMsgs)
if err != nil {
return 0, 0, nil, err
}
//_, err = db.msg.SetMessagesToCache(ctx, conversationID, mongoMsgs)
//if err != nil {
// return 0, 0, nil, err
//}
}
return minSeq, maxSeq, successMsgs, nil
}
Expand Down

0 comments on commit c328d39

Please sign in to comment.