Merge branch 'develop' into standalone_develop
This commit is contained in:
commit
64e608ffd7
|
@ -5,11 +5,12 @@ class Api::V1::Projects::WebhooksController < Api::V1::BaseController
|
|||
def index
|
||||
# @result_object = Api::V1::Projects::Webhooks::ListService.call(@project, current_user&.gitea_token)
|
||||
@webhooks = @project.webhooks
|
||||
@webhooks = @webhooks.where(type: params[:type]) if params[:type].present?
|
||||
@webhooks = kaminari_paginate(@webhooks)
|
||||
end
|
||||
|
||||
def create
|
||||
@result_object = Api::V1::Projects::Webhooks::CreateService.call(@project, webhook_params, current_user&.gitea_token)
|
||||
@result_object = Api::V1::Projects::Webhooks::CreateService.call(@project, create_webhook_params, current_user&.gitea_token)
|
||||
end
|
||||
|
||||
def show
|
||||
|
@ -44,6 +45,10 @@ class Api::V1::Projects::WebhooksController < Api::V1::BaseController
|
|||
end
|
||||
|
||||
private
|
||||
def create_webhook_params
|
||||
params.require(:webhook).permit(:active, :branch_filter, :http_method, :url, :content_type, :secret, :type, events: [])
|
||||
end
|
||||
|
||||
def webhook_params
|
||||
params.require(:webhook).permit(:active, :branch_filter, :http_method, :url, :content_type, :secret, events: [])
|
||||
end
|
||||
|
|
|
@ -903,6 +903,7 @@ await octokit.request('GET /api/v1/yystopf/ceshi_commit/pulls/3/versions/33/diff
|
|||
|is_renamed|bool|是否重命名|
|
||||
|is_ambiguous|bool||
|
||||
|is_submodule|bool|是否为子模块|
|
||||
|diff|string|git diff内容|
|
||||
|sections.file_name|string|文件名称|
|
||||
|sections.name|string||
|
||||
|sections.lines.left_index|int|文件变动之前所在行数|
|
||||
|
|
|
@ -2283,7 +2283,7 @@ await octokit.request('POST /api/v1/yystopf/ceshi/webhooks.json')
|
|||
|webhook.active |是| | bool | 是否激活|
|
||||
|webhook.branch_filter|否| |string|分支过滤|
|
||||
|webhook.events |否| |array|触发事件|
|
||||
|
||||
|webhook.type |否| gitea |string| hook类型,gitea slack discord dingtalk telegram msteams feishu matrix jianmu|
|
||||
触发事件字段说明
|
||||
|
||||
参数| 含义|
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
class Api::V1::Projects::Webhooks::CreateService < ApplicationService
|
||||
include ActiveModel::Model
|
||||
|
||||
attr_reader :project, :token, :owner, :repo, :active, :branch_filter, :content_type, :url, :http_method, :secret, :events
|
||||
attr_reader :project, :token, :owner, :repo, :active, :branch_filter, :content_type, :url, :http_method, :secret, :events, :type
|
||||
attr_accessor :gitea_data
|
||||
|
||||
validates :url, format: { with: URI::regexp(%w[http https]), message: "请输入正确的地址" }
|
||||
validates :active, inclusion: {in: [true, false]}
|
||||
validates :http_method, inclusion: { in: %w(POST GET), message: "请输入正确的请求方式"}
|
||||
validates :content_type, inclusion: { in: %w(json form), message: "请输入正确的Content Type"}
|
||||
|
||||
validates :type, inclusion: {in: %w(gitea slack discord dingtalk telegram msteams feishu matrix jianmu), message: "请输入正确的Webhook Type"}
|
||||
def initialize(project, params, token=nil)
|
||||
@project = project
|
||||
@owner = project&.owner.login
|
||||
|
@ -20,6 +20,7 @@ class Api::V1::Projects::Webhooks::CreateService < ApplicationService
|
|||
@http_method = params[:http_method]
|
||||
@secret = params[:secret]
|
||||
@events = params[:events]
|
||||
@type = params[:type] || "gitea"
|
||||
@token = token
|
||||
end
|
||||
|
||||
|
@ -52,7 +53,7 @@ class Api::V1::Projects::Webhooks::CreateService < ApplicationService
|
|||
secret: secret
|
||||
},
|
||||
events: events || [],
|
||||
type: 'gitea',
|
||||
type: type,
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
json.(webhook, :id, :url, :http_method, :is_active)
|
||||
json.(webhook, :id, :url, :http_method, :is_active, :type)
|
||||
json.last_status webhook.last_status
|
||||
json.create_time Time.at(webhook.created_unix).strftime("%Y-%m-%d %H:%M:%S")
|
|
@ -1,4 +1,5 @@
|
|||
json.id webhook["id"]
|
||||
json.type webhook["type"]
|
||||
json.content_type webhook['config']['content_type']
|
||||
json.http_method webhook['config']['http_method']
|
||||
json.url webhook['config']['url']
|
||||
|
|
|
@ -11384,6 +11384,13 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks.json
|
|||
<td>array</td>
|
||||
<td>触发事件</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>webhook.type</td>
|
||||
<td>否</td>
|
||||
<td>gitea</td>
|
||||
<td>string</td>
|
||||
<td>hook类型,gitea slack discord dingtalk telegram msteams feishu matrix jianmu</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
|
||||
<p>触发事件字段说明 </p>
|
||||
|
@ -14335,6 +14342,11 @@ http://localhost:3000/api/v1/yystopf/ceshi_commit/pulls/3/versions/33/diff.json
|
|||
<td>是否为子模块</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>diff</td>
|
||||
<td>string</td>
|
||||
<td>git diff内容</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>sections.file_name</td>
|
||||
<td>string</td>
|
||||
<td>文件名称</td>
|
||||
|
|
Loading…
Reference in New Issue