|
|
@ -16,16 +16,15 @@ package msg
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"context"
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/util/conversationutil"
|
|
|
|
|
|
|
|
"github.com/openimsdk/tools/utils/datautil"
|
|
|
|
|
|
|
|
"github.com/openimsdk/tools/utils/timeutil"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/msgprocessor"
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/msgprocessor"
|
|
|
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/util/conversationutil"
|
|
|
|
"github.com/openimsdk/protocol/constant"
|
|
|
|
"github.com/openimsdk/protocol/constant"
|
|
|
|
"github.com/openimsdk/protocol/msg"
|
|
|
|
"github.com/openimsdk/protocol/msg"
|
|
|
|
"github.com/openimsdk/protocol/sdkws"
|
|
|
|
"github.com/openimsdk/protocol/sdkws"
|
|
|
|
"github.com/openimsdk/tools/log"
|
|
|
|
"github.com/openimsdk/tools/log"
|
|
|
|
|
|
|
|
"github.com/openimsdk/tools/utils/datautil"
|
|
|
|
|
|
|
|
"github.com/openimsdk/tools/utils/timeutil"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
@ -87,26 +86,32 @@ func (m *msgServer) PullMessageBySeqs(ctx context.Context, req *sdkws.PullMessag
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (m *msgServer) GetSeqMessage(ctx context.Context, req *msg.GetSeqMessageReq) (*msg.GetSeqMessageResp, error) {
|
|
|
|
func (m *msgServer) GetSeqMessage(ctx context.Context, req *msg.GetSeqMessageReq) (*msg.GetSeqMessageResp, error) {
|
|
|
|
conversations := make(map[string]*msg.ConversationMessage)
|
|
|
|
resp := &msg.GetSeqMessageResp{
|
|
|
|
|
|
|
|
Msgs: make(map[string]*sdkws.PullMsgs),
|
|
|
|
|
|
|
|
NotificationMsgs: make(map[string]*sdkws.PullMsgs),
|
|
|
|
|
|
|
|
}
|
|
|
|
for _, conv := range req.Conversations {
|
|
|
|
for _, conv := range req.Conversations {
|
|
|
|
if _, ok := conversations[conv.ConversationID]; !ok {
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_, _, msgs, err := m.MsgDatabase.GetMsgBySeqs(ctx, req.UserID, conv.ConversationID, conv.Seqs)
|
|
|
|
_, _, msgs, err := m.MsgDatabase.GetMsgBySeqs(ctx, req.UserID, conv.ConversationID, conv.Seqs)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
values := make(map[int64]*sdkws.MsgData)
|
|
|
|
var pullMsgs *sdkws.PullMsgs
|
|
|
|
for i, data := range msgs {
|
|
|
|
if ok := false; conversationutil.IsNotificationConversationID(conv.ConversationID) {
|
|
|
|
values[data.Seq] = msgs[i]
|
|
|
|
pullMsgs, ok = resp.NotificationMsgs[conv.ConversationID]
|
|
|
|
}
|
|
|
|
if !ok {
|
|
|
|
conversations[conv.ConversationID] = &msg.ConversationMessage{
|
|
|
|
pullMsgs = &sdkws.PullMsgs{}
|
|
|
|
Msgs: values,
|
|
|
|
resp.NotificationMsgs[conv.ConversationID] = pullMsgs
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
pullMsgs, ok = resp.Msgs[conv.ConversationID]
|
|
|
|
|
|
|
|
if !ok {
|
|
|
|
|
|
|
|
pullMsgs = &sdkws.PullMsgs{}
|
|
|
|
|
|
|
|
resp.NotificationMsgs[conv.ConversationID] = pullMsgs
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pullMsgs.Msgs = append(pullMsgs.Msgs, msgs...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return &msg.GetSeqMessageResp{
|
|
|
|
return resp, nil
|
|
|
|
Conversations: conversations,
|
|
|
|
|
|
|
|
}, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (m *msgServer) GetMaxSeq(ctx context.Context, req *sdkws.GetMaxSeqReq) (*sdkws.GetMaxSeqResp, error) {
|
|
|
|
func (m *msgServer) GetMaxSeq(ctx context.Context, req *sdkws.GetMaxSeqReq) (*sdkws.GetMaxSeqResp, error) {
|
|
|
|