Skip to content

Commit

Permalink
feat: change level del request (#719)
Browse files Browse the repository at this point in the history
  • Loading branch information
icey-yu authored Sep 27, 2024
1 parent 1331870 commit c661189
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/group/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,7 @@ func (g *Group) FetchGroupOrError(ctx context.Context, groupID string) (*model_s
}
return groups[0], nil
}

func (g *Group) delLocalGroupRequest(ctx context.Context, groupID, userID string) error {
return g.db.DeleteGroupRequest(ctx, groupID, userID)
}
13 changes: 13 additions & 0 deletions internal/group/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ func (g *Group) doNotification(ctx context.Context, msg *sdkws.MsgData) error {
if detail.Group == nil {
return errs.New(fmt.Sprintf("group is nil, groupID: %s", detail.Group.GroupID)).Wrap()
}
if detail.NewGroupOwner.RoleLevel < constant.GroupAdmin && detail.OldGroupOwner == g.loginUserID {
if err := g.delLocalGroupRequest(ctx, detail.Group.GroupID, g.loginUserID); err != nil {
return err
}
}
return g.onlineSyncGroupAndMember(ctx, detail.Group.GroupID, nil,
[]*sdkws.GroupMemberFullInfo{detail.NewGroupOwner, detail.OldGroupOwnerInfo}, nil,
detail.Group, groupSortIDChanged, detail.GroupMemberVersion, detail.GroupMemberVersionID)
Expand All @@ -136,6 +141,9 @@ func (g *Group) doNotification(ctx context.Context, msg *sdkws.MsgData) error {
}
}
if self {
if err := g.delLocalGroupRequest(ctx, detail.Group.GroupID, g.loginUserID); err != nil {
return err
}
return g.IncrSyncJoinGroup(ctx)
} else {
return g.onlineSyncGroupAndMember(ctx, detail.Group.GroupID, detail.KickedUserList, nil,
Expand Down Expand Up @@ -233,6 +241,11 @@ func (g *Group) doNotification(ctx context.Context, msg *sdkws.MsgData) error {
if err := utils.UnmarshalNotificationElem(msg.Content, &detail); err != nil {
return err
}
if detail.ChangedUser.UserID == g.loginUserID {
if err := g.delLocalGroupRequest(ctx, detail.Group.GroupID, g.loginUserID); err != nil {
return err
}
}
return g.onlineSyncGroupAndMember(ctx, detail.Group.GroupID, nil,
[]*sdkws.GroupMemberFullInfo{detail.ChangedUser}, nil, nil,
detail.GroupSortVersion, detail.GroupMemberVersion, detail.GroupMemberVersionID)
Expand Down

0 comments on commit c661189

Please sign in to comment.