From cbdbc4b25e6044d0e082a9facb5ea588a5e76906 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 29 Aug 2024 17:08:31 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fixed=20=E4=B8=AA=E4=BA=BA=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=88=97=E8=A1=A8=E6=9D=A1=E4=BB=B6=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E5=90=8D=E6=9F=A5=E8=AF=A2,=E7=B4=A2?= =?UTF-8?q?=E5=BC=95=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/queries/projects/list_my_query.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/queries/projects/list_my_query.rb b/app/queries/projects/list_my_query.rb index df5fca8b6..32a9ee787 100644 --- a/app/queries/projects/list_my_query.rb +++ b/app/queries/projects/list_my_query.rb @@ -88,7 +88,9 @@ class Projects::ListMyQuery < ApplicationQuery else if @home_top_ids.present? scope = scope.distinct.order("FIELD(projects.id, #{@home_top_ids.join(",")}) desc, projects.#{sort} #{sort_direction}") - else + elsif params[:topic_name].present? + scope = scope.distinct.order("project_topics.id asc, projects.#{sort} #{sort_direction}") + else scope = scope.distinct.order("projects.#{sort} #{sort_direction}") end end From 973e18812cc35b099d22077d23c63bb61ee24715 Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 4 Sep 2024 14:33:47 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9Agitlink=E3=80=81?= =?UTF-8?q?gitea=E3=80=81gitcode=E7=9A=84token=E6=A0=A1=E9=AA=8C=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E8=AF=B7=E6=B1=82=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E7=9A=84=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../projects/verify_auth_token_service.rb | 68 ++++++++++++++++--- 1 file changed, 59 insertions(+), 9 deletions(-) diff --git a/app/services/projects/verify_auth_token_service.rb b/app/services/projects/verify_auth_token_service.rb index 36dcb106f..1f6b7a076 100644 --- a/app/services/projects/verify_auth_token_service.rb +++ b/app/services/projects/verify_auth_token_service.rb @@ -36,16 +36,66 @@ class Projects::VerifyAuthTokenService < ApplicationService gitlab_verify when "gitee.com" gitee_verify + when "gitlink.org.cn" + gitlink_verify + when "gitea.com" + gitea_verify + when "gitcode.com" + gitcode_verify + else + @success = nil end end + def gitcode_verify + url = "/api/v5/user" + api_url = "https://api.gitcode.com" + client = Faraday.new(url: api_url) + client.options["open_timeout"] = 100 + client.options["timeout"] = 100 + client.options["write_timeout"] = 100 + req_params={ + access_token: @token + } + response = client.public_send("get", url, req_params) + @success = true if response.status == 200 + end + + def gitea_verify + url = "/api/v1/user" + api_url = "https://gitea.com" + client = Faraday.new(url: api_url) + client.options["open_timeout"] = 100 + client.options["timeout"] = 100 + client.options["write_timeout"] = 100 + req_params={ + token: @token + } + response = client.public_send("get", url, req_params) + @success = true if response.status == 200 + end + + def gitlink_verify + url = "/api/v1/user" + api_url = "https://cdn05042023.gitlink.org.cn" + client = Faraday.new(url: api_url) + client.options["open_timeout"] = 100 + client.options["timeout"] = 100 + client.options["write_timeout"] = 100 + req_params={ + token: @token + } + response = client.public_send("get", url, req_params) + @success = true if response.status == 200 + end + def gitee_verify url = "/api/v5/repos/#{@owner}/#{@repo}" api_url= "https://gitee.com" client = Faraday.new(url: api_url) - client.options["open_timeout"] = 1 - client.options["timeout"] = 1 - client.options["write_timeout"] = 1 + client.options["open_timeout"] = 100 + client.options["timeout"] = 100 + client.options["write_timeout"] = 100 req_params={ access_token: @token, owner: @owner, @@ -59,9 +109,9 @@ class Projects::VerifyAuthTokenService < ApplicationService url = "/octocat" api_url= "https://api.github.com" client = Faraday.new(url: api_url) - client.options["open_timeout"] = 1 - client.options["timeout"] = 1 - client.options["write_timeout"] = 1 + client.options["open_timeout"] = 100 + client.options["timeout"] = 100 + client.options["write_timeout"] = 100 client.headers["Authorization"] = "Bearer #{@token}" response = client.public_send("get", url) @success = true if response.status == 200 @@ -71,9 +121,9 @@ class Projects::VerifyAuthTokenService < ApplicationService url = "/api/v4/projects" api_url= "https://gitlab.com" client = Faraday.new(url: api_url) - client.options["open_timeout"] = 1 - client.options["timeout"] = 1 - client.options["write_timeout"] = 1 + client.options["open_timeout"] = 100 + client.options["timeout"] = 100 + client.options["write_timeout"] = 100 req_params={ private_token: @token } From 033c65b46faea06aca1298b9145940822492a12c Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 5 Sep 2024 09:18:07 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9AThe=20target=20c?= =?UTF-8?q?ouldn't=20be=20found?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 5e036ff51..b3a0c3aa5 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -314,8 +314,8 @@ class ProjectsController < ApplicationController def simple if !@project.common? && @project&.repository&.mirror&.waiting? - gitea_result = $gitea_client.get_repos_by_owner_repo(@project&.owner&.login, @project&.identifier) - if !gitea_result["empty"] + gitea_result = $gitea_client.get_repos_by_owner_repo(@project&.owner&.login, @project&.identifier) rescue nil + if gitea_result.present? && !gitea_result["empty"] @project&.update_columns(gpid: gitea_result["id"]) @project&.repository&.mirror&.succeeded! project_id = @project&.id