From c591a445f01f60cbf180327a330baa93f0ad722f Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 29 Apr 2024 09:07:36 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20=E8=A7=A3=E6=95=A3=E5=9B=A2=E9=98=9F?= =?UTF-8?q?=E4=B8=AD=E6=88=90=E5=91=98=E5=9C=A8=E5=85=B6=E4=BB=96=E7=BB=84?= =?UTF-8?q?=E7=BB=87=E5=85=B6=E4=BB=96=E5=9B=A2=E9=98=9F=E4=B8=8D=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E7=9A=84=E6=88=90=E5=91=98=E9=9C=80=E6=B8=85=E9=99=A4?= =?UTF-8?q?=E7=BB=84=E7=BB=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/organizations/teams_controller.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/controllers/organizations/teams_controller.rb b/app/controllers/organizations/teams_controller.rb index 09f5bc3f0..90bc4a534 100644 --- a/app/controllers/organizations/teams_controller.rb +++ b/app/controllers/organizations/teams_controller.rb @@ -67,7 +67,17 @@ class Organizations::TeamsController < Organizations::BaseController tip_exception("组织团队不允许被删除") if @team.owner? ActiveRecord::Base.transaction do Gitea::Organization::Team::DeleteService.call(@organization.gitea_token, @team.gtid) + all_user_ids = @organization.team_users.pluck(:user_id) + team_user_ids = @team.team_users.pluck(:user_id) + # 当前删除团队中成员在其他组织其他团队不存在的成员需清除组织 + remove_user_ids = team_user_ids - all_user_ids @team.destroy! + if remove_user_ids.present? + User.where(id: remove_user_ids).each do |user| + @organization.organization_users.find_by(user_id: user.id).destroy! + Gitea::Organization::OrganizationUser::DeleteService.call(@organization.gitea_token, @organization.login, user.login) + end + end end render_ok rescue Exception => e