conversation

test-errcode
wangchuxiao 2 years ago
parent 9c76988225
commit 5d617cc240

@ -22,17 +22,18 @@ import (
type MessageInterceptorChain []MessageInterceptorFunc type MessageInterceptorChain []MessageInterceptorFunc
type msgServer struct { type msgServer struct {
RegisterCenter discoveryregistry.SvcDiscoveryRegistry RegisterCenter discoveryregistry.SvcDiscoveryRegistry
MsgDatabase controller.MsgDatabase MsgDatabase controller.MsgDatabase
ExtendMsgDatabase controller.ExtendMsgDatabase notificationDatabase controller.NotificationDatabase
Group *rpcclient.GroupClient ExtendMsgDatabase controller.ExtendMsgDatabase
User *rpcclient.UserClient Group *rpcclient.GroupClient
Conversation *rpcclient.ConversationClient User *rpcclient.UserClient
friend *rpcclient.FriendClient Conversation *rpcclient.ConversationClient
black *rpcclient.BlackClient friend *rpcclient.FriendClient
GroupLocalCache *localcache.GroupLocalCache black *rpcclient.BlackClient
MessageLocker MessageLocker GroupLocalCache *localcache.GroupLocalCache
Handlers MessageInterceptorChain MessageLocker MessageLocker
Handlers MessageInterceptorChain
} }
func (m *msgServer) addInterceptorHandler(interceptorFunc ...MessageInterceptorFunc) { func (m *msgServer) addInterceptorHandler(interceptorFunc ...MessageInterceptorFunc) {
@ -161,14 +162,31 @@ func (m *msgServer) GetMaxAndMinSeq(ctx context.Context, req *sdkws.GetMaxAndMin
func (m *msgServer) PullMessageBySeqs(ctx context.Context, req *sdkws.PullMessageBySeqsReq) (*sdkws.PullMessageBySeqsResp, error) { func (m *msgServer) PullMessageBySeqs(ctx context.Context, req *sdkws.PullMessageBySeqsReq) (*sdkws.PullMessageBySeqsResp, error) {
resp := &sdkws.PullMessageBySeqsResp{} resp := &sdkws.PullMessageBySeqsResp{}
for _, seq := range req.SeqRanges { for _, seq := range req.SeqRanges {
msgs, err := m.MsgDatabase.GetMsgBySeqsRange(ctx, seq.ConversationID, seq.Begin, seq.End, seq.Num) if !seq.IsNotification {
if err != nil { msgs, err := m.MsgDatabase.GetMsgBySeqsRange(ctx, seq.ConversationID, seq.Begin, seq.End, seq.Num)
return nil, err if err != nil {
return nil, err
}
resp.Msgs = append(resp.Msgs, &sdkws.PullMsgs{
ConversationID: seq.ConversationID,
Msgs: msgs,
})
} else {
var seqs []int64
for i := seq.Begin; i <= seq.End; i++ {
seqs = append(seqs, i)
}
msgs, err := m.notificationDatabase.GetMsgBySeqs(ctx, seq.ConversationID, seqs)
if err != nil {
return nil, err
}
resp.Msgs = append(resp.Msgs, &sdkws.PullMsgs{
ConversationID: seq.ConversationID,
Msgs: msgs,
IsNotification: true,
})
} }
resp.Msgs = append(resp.Msgs, &sdkws.PullMsgs{
ConversationID: seq.ConversationID,
Msgs: msgs,
})
} }
return resp, nil return resp, nil
} }

Loading…
Cancel
Save