conversations

test-errcode
wangchuxiao 2 years ago
parent c0f8b9910a
commit 5f7fa2a7a2

@ -70,6 +70,7 @@ type groupServer struct {
User *rpcclient.UserClient
Notification *notification.GroupNotificationSender
conversationRpcClient *rpcclient.ConversationClient
msgRpcClient *rpcclient.MsgClient
}
func (s *groupServer) CheckGroupAdmin(ctx context.Context, groupID string) error {
@ -462,6 +463,9 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
}
s.Notification.MemberKickedNotification(ctx, req, req.KickedUserIDs)
}
if err := s.deleteMemberAndSetConversationSeq(ctx, req.GroupID, req.KickedUserIDs); err != nil {
return nil, err
}
return resp, nil
}
@ -721,9 +725,28 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq)
}
s.Notification.MemberQuitNotification(ctx, req)
}
if err := s.deleteMemberAndSetConversationSeq(ctx, req.GroupID, []string{mcontext.GetOpUserID(ctx)}); err != nil {
return nil, err
}
return resp, nil
}
func (s *groupServer) deleteMemberAndSetConversationSeq(ctx context.Context, groupID string, userIDs []string) error {
conevrsationID := utils.GetConversationIDBySessionType(constant.SuperGroupChatType, groupID)
resp, err := s.msgRpcClient.GetMaxAndMinSeq(ctx, &sdkws.GetMaxAndMinSeqReq{
ConversationIDs: []string{},
UserID: mcontext.GetOpUserID(ctx),
})
if err != nil {
return err
}
seq, ok := resp.MaxAndMinSeqs[conevrsationID]
if !ok {
return errs.ErrInternalServer.Wrap("get max seq error")
}
return s.conversationRpcClient.DelGroupChatConversations(ctx, userIDs, groupID, seq.MaxSeq)
}
func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInfoReq) (*pbGroup.SetGroupInfoResp, error) {
if !tokenverify.IsAppManagerUid(ctx) {
groupMember, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupInfoForSet.GroupID, mcontext.GetOpUserID(ctx))

@ -129,34 +129,22 @@ func (m *msgServer) GetMaxAndMinSeq(ctx context.Context, req *sdkws.GetMaxAndMin
}
m2 := make(map[string]*sdkws.MaxAndMinSeq)
maxSeq, err := m.MsgDatabase.GetUserMaxSeq(ctx, req.UserID)
if err != nil && errs.Unwrap(err) != redis.Nil {
return nil, err
}
minSeq, err := m.MsgDatabase.GetUserMinSeq(ctx, req.UserID)
if err != nil && errs.Unwrap(err) != redis.Nil {
return nil, err
}
resp := new(sdkws.GetMaxAndMinSeqResp)
resp.MaxSeq = maxSeq
resp.MinSeq = minSeq
for _, groupID := range req.GroupIDs {
maxSeq, err := m.MsgDatabase.GetGroupMaxSeq(ctx, groupID)
for _, conversationID := range req.ConversationIDs {
maxSeq, err := m.MsgDatabase.GetGroupMaxSeq(ctx, conversationID)
if err != nil && errs.Unwrap(err) != redis.Nil {
return nil, err
}
minSeq, err := m.MsgDatabase.GetGroupMinSeq(ctx, groupID)
minSeq, err := m.MsgDatabase.GetGroupMinSeq(ctx, conversationID)
if err != nil && errs.Unwrap(err) != redis.Nil {
return nil, err
}
m2[groupID] = &sdkws.MaxAndMinSeq{
m2[conversationID] = &sdkws.MaxAndMinSeq{
MaxSeq: maxSeq,
MinSeq: minSeq,
}
}
resp.GroupMaxAndMinSeq = m2
resp.MaxAndMinSeqs = m2
return resp, nil
}

File diff suppressed because it is too large Load Diff

@ -146,7 +146,7 @@ message PullMessageBySeqsResp {
}
message GetMaxAndMinSeqReq {
repeated string groupIDs = 1;
repeated string conversationIDs = 1;
string userID = 2;
}
message MaxAndMinSeq{
@ -154,9 +154,7 @@ message MaxAndMinSeq{
int64 minSeq = 2;
}
message GetMaxAndMinSeqResp {
int64 maxSeq = 1;
int64 minSeq = 2;
map<string, MaxAndMinSeq> groupMaxAndMinSeq = 5;
map<string, MaxAndMinSeq> MaxAndMinSeqs = 1;
}
message UserSendMsgResp {

Loading…
Cancel
Save