forked from Trustie/forgeplus
30 lines
695 B
Ruby
30 lines
695 B
Ruby
class Api::V1::Projects::Webhooks::DeleteService < ApplicationService
|
|
|
|
attr_reader :project, :id, :token, :owner, :repo
|
|
attr_accessor :gitea_data
|
|
|
|
def initialize(project, id, token=nil)
|
|
@project = project
|
|
@id = id
|
|
@owner = project&.owner.login
|
|
@repo = project&.identifier
|
|
@token = token
|
|
end
|
|
|
|
def call
|
|
$gitea_client.token = token unless token.blank?
|
|
excute_data_to_gitea
|
|
|
|
$gitea_client.token = nil unless token.blank?
|
|
|
|
gitea_data
|
|
rescue
|
|
raise Error, "服务器错误,请联系系统管理员!"
|
|
end
|
|
|
|
private
|
|
|
|
def excute_data_to_gitea
|
|
@gitea_data = $gitea_client.delete_repos_hooks_by_owner_repo_id(owner, repo, id)
|
|
end
|
|
end |