mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 03:40:49 +08:00
修改:自定义事件
This commit is contained in:
36
app/services/webhook/pull_comment_client.rb
Normal file
36
app/services/webhook/pull_comment_client.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
class Webhook::PullCommentClient
|
||||
include Webhook::Client
|
||||
|
||||
attr_accessor :webhook, :pull, :journal, :sender, :event
|
||||
|
||||
def initialize(webhook, pull, journal, sender, event)
|
||||
@webhook = webhook
|
||||
@pull = pull
|
||||
@journal = journal
|
||||
@sender = sender
|
||||
@event = event
|
||||
|
||||
# 构建client参数
|
||||
super({
|
||||
uuid: SecureRandom.uuid,
|
||||
event: @event,
|
||||
webhook: @webhook,
|
||||
payload_content: payload_content
|
||||
})
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def payload_content
|
||||
{
|
||||
"action": "created",
|
||||
"number": @pull.gitea_number,
|
||||
"pull_request": JSON.parse(@pull.to_builder.target!),
|
||||
"comment": JSON.parse(@journal.to_builder.target!),
|
||||
"project": JSON.parse(@pull.project.to_builder.target!),
|
||||
"sender": JSON.parse(@sender.to_builder.target!),
|
||||
"is_pull": true
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user