From c9659fd926810a435a848ad719c76fea3a3b5b4c Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 22 Aug 2023 12:25:15 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20fork=E5=90=8E=E9=87=8D=E5=91=BD?= =?UTF-8?q?=E5=90=8D=E9=A1=B9=E7=9B=AE=E6=A0=87=E8=AF=86=E5=86=8Dforked?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/forks_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/forks_controller.rb b/app/controllers/forks_controller.rb index 141ecf13b..a27f6668d 100644 --- a/app/controllers/forks_controller.rb +++ b/app/controllers/forks_controller.rb @@ -12,9 +12,9 @@ class ForksController < ApplicationController def authenticate_project! if current_user&.id == @project.user_id render_result(-1, "自己不能fork自己的项目") - elsif ForkUser.exists?(fork_project_id: @project.id, user_id: current_user.id) - fork = ForkUser.find_by(fork_project_id: @project.id, user_id: current_user.id) - render json: { status: -1, identifier: fork.fork_project&.identifier, message: "fork失败,你已拥有了这个项目" } + elsif @project.fork_users.where(user_id: current_user.id).present? + fork = @project.fork_users.find_by(user_id: current_user.id) + render json: { status: 0, id: fork.fork_project_id, identifier: fork.fork_project&.identifier, message: "fork失败,你已拥有了这个项目 #{fork.fork_project&.identifier}" } return elsif Project.exists?(user_id: current_user.id, identifier: @project.identifier) render_result(0, "fork失败,你已拥有了这个项目")