From 56103a885b24398f90fd20d1d013483c92add028 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 22 Aug 2023 13:47:34 +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 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/controllers/forks_controller.rb b/app/controllers/forks_controller.rb index 0842d2e67..8215192f2 100644 --- a/app/controllers/forks_controller.rb +++ b/app/controllers/forks_controller.rb @@ -12,6 +12,10 @@ class ForksController < ApplicationController def authenticate_project! if current_user&.id == @project.user_id render_result(-1, "自己不能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失败,你已拥有了这个项目") end