| @@ -1,6 +1,7 @@ | |||||
| class Organizations::ClasController < Organizations::BaseController | class Organizations::ClasController < Organizations::BaseController | ||||
| before_action :load_organization | before_action :load_organization | ||||
| before_action :load_cla, only: [:show, :update, :destroy] | before_action :load_cla, only: [:show, :update, :destroy] | ||||
| before_action :check_user_can_edit_org, only: [:create, :update, :destroy] | |||||
| def index | def index | ||||
| @cla = @organization.cla | @cla = @organization.cla | ||||
| @@ -67,6 +67,7 @@ class PullRequestsController < ApplicationController | |||||
| Issues::CreateForm.new({subject: params[:title], description: params[:body].blank? ? params[:body] : params[:body].b}).validate! | Issues::CreateForm.new({subject: params[:title], description: params[:body].blank? ? params[:body] : params[:body].b}).validate! | ||||
| @pull_request, @gitea_pull_request = PullRequests::CreateService.call(current_user, @owner, @project, params) | @pull_request, @gitea_pull_request = PullRequests::CreateService.call(current_user, @owner, @project, params) | ||||
| if @gitea_pull_request[:status] == :success | if @gitea_pull_request[:status] == :success | ||||
| PullRequests::SendJournalService.call(@project, @pull_request, current_user) | |||||
| @pull_request.bind_gitea_pull_request!(@gitea_pull_request[:body]["number"], @gitea_pull_request[:body]["id"]) | @pull_request.bind_gitea_pull_request!(@gitea_pull_request[:body]["number"], @gitea_pull_request[:body]["id"]) | ||||
| reviewers = User.where(id: params[:reviewer_ids]) | reviewers = User.where(id: params[:reviewer_ids]) | ||||
| @pull_request.reviewers = reviewers | @pull_request.reviewers = reviewers | ||||
| @@ -0,0 +1,32 @@ | |||||
| class PullRequests::SendJournalService < ApplicationService | |||||
| def initialize(project, pull_request,current_user) | |||||
| @project = project | |||||
| @issue = pull_request | |||||
| @current_user = current_user | |||||
| @org = project.owner | |||||
| end | |||||
| def call | |||||
| if @org.enabling_cla && @org.cla.present? && @org.cla.pr_need && !@org.is_member?(@current_user&.id) | |||||
| ActiveRecord::Base.transaction do | |||||
| sender_id = if Rails.env.development? | |||||
| User.last.id | |||||
| else | |||||
| 87461 | |||||
| end | |||||
| journal_params = { | |||||
| journalized_id: @issue.id , | |||||
| journalized_type: "Issue", | |||||
| user_id: sender_id , | |||||
| notes: "@xxx 您好!欢迎参与 #{@project.name} 的贡献。首次进行贡献请完成《<a href='/#{@project.owner.login}/cla/#{@project.owner.cla.key}' target='_blank'>#{@project.owner.cla.name}</a>》的签署,签署完成后,项目成员才可查看到您的合并请求", | |||||
| } | |||||
| journal = Journal.new journal_params | |||||
| if journal.save | |||||
| TouchWebhookJob.set(wait: 5.seconds).perform_later('PullRequestComment', @issue&.id, sender_id, journal.id, 'created', {}) | |||||
| push_activity_2_blockchain("issue_comment_create", journal) if Site.has_blockchain? && @project.use_blockchain | |||||
| end | |||||
| end | |||||
| end | |||||
| end | |||||
| end | |||||