diff --git a/app/controllers/api/v1/projects/pipelines_controller.rb b/app/controllers/api/v1/projects/pipelines_controller.rb index 68305a40b..9e20d9ffa 100644 --- a/app/controllers/api/v1/projects/pipelines_controller.rb +++ b/app/controllers/api/v1/projects/pipelines_controller.rb @@ -47,6 +47,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController interactor = sha.present? ? Gitea::UpdateFileInteractor.call(current_user.gitea_token, @owner.login, content_params("update").merge(sha: sha)) : Gitea::CreateFileInteractor.call(current_user.gitea_token, @owner.login, content_params("create")) tip_exception(interactor.error) unless interactor.success? file = interactor.result + @pipeline.save render_ok({ pipeline_yaml: pipeline_yaml, pipeline_name: params[:pipeline_name], file_name: @pipeline.file_name, sha: sha.present? ? sha : file['content']['sha'] }) end @@ -79,8 +80,8 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController def destroy @pipeline = Action::Pipeline.find(params[:id]) - if pipeline - interactor = Gitea::DeleteFileInteractor.call(current_user.gitea_token, @owner.login, content_params("update")) + if @pipeline + interactor = Gitea::DeleteFileInteractor.call(current_user.gitea_token, @owner.login, del_content_params.merge(identifier: @project.identifier)) tip_exception(interactor.error) unless interactor.success? @pipeline.destroy! end @@ -172,6 +173,15 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController } end + def del_content_params(opt) + { + filepath: ".gitea/workflows/#{@pipeline.pipeline_name}.yml", + base64_filepath: Base64.encode64(".gitea/workflows/#{@pipeline.pipeline_name}.yml").gsub(/\n/, ''), + branch: @pipeline.branch, + sha: get_pipeline_file_sha(@pipeline.file_name, @pipeline.branch) + } + end + def build_nodes(params_nodes) steps_nodes = [] params_nodes.each do |input_node| diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 761a88fa8..4c18cac4b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -263,7 +263,7 @@ class UsersController < ApplicationController begin @user = current_user begin - result = Notice::Read::CountService.call(current_user.id) + result = EduSetting.get("notice_disable").to_s == "true" ? nil : Notice::Read::CountService.call(current_user.id) @message_unread_total = result.nil? ? 0 : result[2]["unread_notification"] rescue @message_unread_total = 0