Skip to content

Commit

Permalink
close conversation when import history msg
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwnloy authored and yuwnloy committed Oct 10, 2024
1 parent 102bb41 commit 329aa22
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 37 deletions.
40 changes: 20 additions & 20 deletions services/group/services/groupmsgservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,25 +265,25 @@ func ImportGroupHisMsg(ctx context.Context, msg *pbobjs.UpMsg) {
memberIds := getMembersExceptMe(ctx, groupId)
memberCount := len(memberIds)
msgId := tools.GenerateMsgId(msg.MsgTime, int32(pbobjs.ChannelType_Group), groupId)
downMsg4Sendbox := &pbobjs.DownMsg{
SenderId: senderId,
TargetId: groupId,
ChannelType: pbobjs.ChannelType_Group,
MsgType: msg.MsgType,
MsgContent: msg.MsgContent,
MsgId: msgId,
MsgSeqNo: -1,
MsgTime: msg.MsgTime,
Flags: msg.Flags,
IsSend: true,
TargetUserInfo: commonservices.GetSenderUserInfo(ctx),
GroupInfo: groupInfo,
MemberCount: int32(memberCount),
}
if commonservices.IsStoreMsg(msg.Flags) {
//add conver for sender
commonservices.BatchSaveConversations(ctx, []string{senderId}, downMsg4Sendbox)
}
// downMsg4Sendbox := &pbobjs.DownMsg{
// SenderId: senderId,
// TargetId: groupId,
// ChannelType: pbobjs.ChannelType_Group,
// MsgType: msg.MsgType,
// MsgContent: msg.MsgContent,
// MsgId: msgId,
// MsgSeqNo: -1,
// MsgTime: msg.MsgTime,
// Flags: msg.Flags,
// IsSend: true,
// TargetUserInfo: commonservices.GetSenderUserInfo(ctx),
// GroupInfo: groupInfo,
// MemberCount: int32(memberCount),
// }
// if commonservices.IsStoreMsg(msg.Flags) {
// //add conver for sender
// commonservices.BatchSaveConversations(ctx, []string{senderId}, downMsg4Sendbox)
// }
downMsg := &pbobjs.DownMsg{
SenderId: senderId,
TargetId: groupId,
Expand All @@ -302,7 +302,7 @@ func ImportGroupHisMsg(ctx context.Context, msg *pbobjs.UpMsg) {
//add hismsg
commonservices.SaveHistoryMsg(ctx, senderId, groupId, pbobjs.ChannelType_Group, downMsg, memberCount)
//add conver for receivers
commonservices.BatchSaveConversations(ctx, memberIds, downMsg)
// commonservices.BatchSaveConversations(ctx, memberIds, downMsg)
}

}
35 changes: 18 additions & 17 deletions services/message/services/msgservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,23 +308,24 @@ func SendPush(ctx context.Context, senderId, receiverId string, msg *pbobjs.Down

func ImportPrivateHisMsg(ctx context.Context, senderId, targetId string, msg *pbobjs.UpMsg) {
msgId := tools.GenerateMsgId(msg.MsgTime, int32(pbobjs.ChannelType_Private), targetId)
downMsg4Sendbox := &pbobjs.DownMsg{
SenderId: senderId,
TargetId: targetId,
ChannelType: pbobjs.ChannelType_Private,
MsgType: msg.MsgType,
MsgContent: msg.MsgContent,
MsgId: msgId,
MsgSeqNo: -1,
MsgTime: msg.MsgTime,
Flags: msg.Flags,
IsSend: true,
//TargetUserInfo: commonservices.GetTargetDisplayUserInfo(ctx, targetId),
}
/*
downMsg4Sendbox := &pbobjs.DownMsg{
SenderId: senderId,
TargetId: targetId,
ChannelType: pbobjs.ChannelType_Private,
MsgType: msg.MsgType,
MsgContent: msg.MsgContent,
MsgId: msgId,
MsgSeqNo: -1,
MsgTime: msg.MsgTime,
Flags: msg.Flags,
IsSend: true,
//TargetUserInfo: commonservices.GetTargetDisplayUserInfo(ctx, targetId),
}*/
// add conver for sender
if commonservices.IsStoreMsg(msg.Flags) {
commonservices.BatchSaveConversations(ctx, []string{senderId}, downMsg4Sendbox)
}
// if commonservices.IsStoreMsg(msg.Flags) {
// commonservices.BatchSaveConversations(ctx, []string{senderId}, downMsg4Sendbox)
// }

downMsg := &pbobjs.DownMsg{
SenderId: senderId,
Expand All @@ -343,6 +344,6 @@ func ImportPrivateHisMsg(ctx context.Context, senderId, targetId string, msg *pb
commonservices.SaveHistoryMsg(ctx, senderId, targetId, pbobjs.ChannelType_Private, downMsg, 0)

//add conver for receiver
commonservices.BatchSaveConversations(ctx, []string{targetId}, downMsg)
//commonservices.BatchSaveConversations(ctx, []string{targetId}, downMsg)
}
}

0 comments on commit 329aa22

Please sign in to comment.