mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-25 11:06:43 +08:00
conversations
This commit is contained in:
parent
c0f8b9910a
commit
5f7fa2a7a2
@ -70,6 +70,7 @@ type groupServer struct {
|
|||||||
User *rpcclient.UserClient
|
User *rpcclient.UserClient
|
||||||
Notification *notification.GroupNotificationSender
|
Notification *notification.GroupNotificationSender
|
||||||
conversationRpcClient *rpcclient.ConversationClient
|
conversationRpcClient *rpcclient.ConversationClient
|
||||||
|
msgRpcClient *rpcclient.MsgClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) CheckGroupAdmin(ctx context.Context, groupID string) error {
|
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)
|
s.Notification.MemberKickedNotification(ctx, req, req.KickedUserIDs)
|
||||||
}
|
}
|
||||||
|
if err := s.deleteMemberAndSetConversationSeq(ctx, req.GroupID, req.KickedUserIDs); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -721,9 +725,28 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq)
|
|||||||
}
|
}
|
||||||
s.Notification.MemberQuitNotification(ctx, req)
|
s.Notification.MemberQuitNotification(ctx, req)
|
||||||
}
|
}
|
||||||
|
if err := s.deleteMemberAndSetConversationSeq(ctx, req.GroupID, []string{mcontext.GetOpUserID(ctx)}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return resp, nil
|
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) {
|
func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInfoReq) (*pbGroup.SetGroupInfoResp, error) {
|
||||||
if !tokenverify.IsAppManagerUid(ctx) {
|
if !tokenverify.IsAppManagerUid(ctx) {
|
||||||
groupMember, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupInfoForSet.GroupID, mcontext.GetOpUserID(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)
|
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 := new(sdkws.GetMaxAndMinSeqResp)
|
||||||
resp.MaxSeq = maxSeq
|
for _, conversationID := range req.ConversationIDs {
|
||||||
resp.MinSeq = minSeq
|
maxSeq, err := m.MsgDatabase.GetGroupMaxSeq(ctx, conversationID)
|
||||||
|
|
||||||
for _, groupID := range req.GroupIDs {
|
|
||||||
maxSeq, err := m.MsgDatabase.GetGroupMaxSeq(ctx, groupID)
|
|
||||||
if err != nil && errs.Unwrap(err) != redis.Nil {
|
if err != nil && errs.Unwrap(err) != redis.Nil {
|
||||||
return nil, err
|
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 {
|
if err != nil && errs.Unwrap(err) != redis.Nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
m2[groupID] = &sdkws.MaxAndMinSeq{
|
m2[conversationID] = &sdkws.MaxAndMinSeq{
|
||||||
MaxSeq: maxSeq,
|
MaxSeq: maxSeq,
|
||||||
MinSeq: minSeq,
|
MinSeq: minSeq,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
resp.MaxAndMinSeqs = m2
|
||||||
resp.GroupMaxAndMinSeq = m2
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -146,7 +146,7 @@ message PullMessageBySeqsResp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message GetMaxAndMinSeqReq {
|
message GetMaxAndMinSeqReq {
|
||||||
repeated string groupIDs = 1;
|
repeated string conversationIDs = 1;
|
||||||
string userID = 2;
|
string userID = 2;
|
||||||
}
|
}
|
||||||
message MaxAndMinSeq{
|
message MaxAndMinSeq{
|
||||||
@ -154,9 +154,7 @@ message MaxAndMinSeq{
|
|||||||
int64 minSeq = 2;
|
int64 minSeq = 2;
|
||||||
}
|
}
|
||||||
message GetMaxAndMinSeqResp {
|
message GetMaxAndMinSeqResp {
|
||||||
int64 maxSeq = 1;
|
map<string, MaxAndMinSeq> MaxAndMinSeqs = 1;
|
||||||
int64 minSeq = 2;
|
|
||||||
map<string, MaxAndMinSeq> groupMaxAndMinSeq = 5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message UserSendMsgResp {
|
message UserSendMsgResp {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user