diff --git a/internal/group/group.go b/internal/group/group.go index 34e1fd77c..e19ade5a2 100644 --- a/internal/group/group.go +++ b/internal/group/group.go @@ -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) +} diff --git a/internal/group/notification.go b/internal/group/notification.go index fa7ab2384..020f9f539 100644 --- a/internal/group/notification.go +++ b/internal/group/notification.go @@ -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) @@ -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, @@ -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)