pull/131/head
Gordon 3 years ago
parent cd7efee49c
commit cbed698a1c

@ -39,10 +39,10 @@ func (rpc *rpcChat) GetMaxAndMinSeq(_ context.Context, in *pbMsg.GetMaxAndMinSeq
func (rpc *rpcChat) PullMessageBySeqList(_ context.Context, in *open_im_sdk.PullMessageBySeqListReq) (*open_im_sdk.PullMessageBySeqListResp, error) { func (rpc *rpcChat) PullMessageBySeqList(_ context.Context, in *open_im_sdk.PullMessageBySeqListReq) (*open_im_sdk.PullMessageBySeqListResp, error) {
log.NewInfo(in.OperationID, "rpc PullMessageBySeqList is arriving", in.String()) log.NewInfo(in.OperationID, "rpc PullMessageBySeqList is arriving", in.String())
resp := new(open_im_sdk.PullMessageBySeqListResp) resp := new(open_im_sdk.PullMessageBySeqListResp)
msgList, err := commonDB.DB.GetMsgBySeqList(in.UserID, in.SeqList) msgList, err := commonDB.DB.GetMsgBySeqList(in.UserID, in.SeqList, in.OperationID)
if err != nil { if err != nil {
log.ErrorByKv("PullMessageBySeqList data error", in.OperationID, in.String()) log.ErrorByKv("PullMessageBySeqList data error", in.OperationID, in.String())
resp.ErrCode = 1 resp.ErrCode = 201
resp.ErrMsg = err.Error() resp.ErrMsg = err.Error()
return resp, nil return resp, nil
} }

@ -61,7 +61,7 @@ func (d *DataBases) GetMinSeqFromMongo(uid string) (MinSeq uint32, err error) {
} }
return MinSeq, nil return MinSeq, nil
} }
func (d *DataBases) GetMsgBySeqList(uid string, seqList []uint32) (seqMsg []*open_im_sdk.MsgData, err error) { func (d *DataBases) GetMsgBySeqList(uid string, seqList []uint32, operationID string) (seqMsg []*open_im_sdk.MsgData, err error) {
var hasSeqList []uint32 var hasSeqList []uint32
singleCount := 0 singleCount := 0
session := d.mgoSession.Clone() session := d.mgoSession.Clone()
@ -86,14 +86,14 @@ func (d *DataBases) GetMsgBySeqList(uid string, seqList []uint32) (seqMsg []*ope
sChat := UserChat{} sChat := UserChat{}
for seqUid, value := range m { for seqUid, value := range m {
if err = c.Find(bson.M{"uid": seqUid}).One(&sChat); err != nil { if err = c.Find(bson.M{"uid": seqUid}).One(&sChat); err != nil {
log.NewError("", "not find seqUid", seqUid, value, uid, seqList) log.NewError(operationID, "not find seqUid", seqUid, value, uid, seqList, err.Error())
continue continue
} }
singleCount = 0 singleCount = 0
for i := 0; i < len(sChat.Msg); i++ { for i := 0; i < len(sChat.Msg); i++ {
msg := new(open_im_sdk.MsgData) msg := new(open_im_sdk.MsgData)
if err = proto.Unmarshal(sChat.Msg[i].Msg, msg); err != nil { if err = proto.Unmarshal(sChat.Msg[i].Msg, msg); err != nil {
log.NewError("", "not find seqUid", seqUid, value, uid, seqList) log.NewError(operationID, "Unmarshal err", seqUid, value, uid, seqList, err.Error())
return nil, err return nil, err
} }
if isContainInt32(msg.Seq, value) { if isContainInt32(msg.Seq, value) {

Loading…
Cancel
Save