mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-17 10:15:57 +08:00
新增:评论丰富更新删除操作,issue事件粒度更细
This commit is contained in:
@@ -70,8 +70,8 @@ class Api::V1::Issues::CreateService < ApplicationService
|
||||
|
||||
# 触发webhook
|
||||
TouchWebhookJob.perform_later('IssueCreate', @created_issue&.id, current_user.id)
|
||||
TouchWebhookJob.perform_later('IssueLabel', @created_issue&.id, current_user.id, issue_tag_ids)
|
||||
TouchWebhookJob.perform_later('IssueAssign', @created_issue&.id, current_user.id, assigner_ids)
|
||||
TouchWebhookJob.perform_later('IssueLabel', @created_issue&.id, current_user.id, issue_tag_ids) unless issue_tag_ids.blank?
|
||||
TouchWebhookJob.perform_later('IssueAssign', @created_issue&.id, current_user.id, assigner_ids) unless assigner_ids.blank?
|
||||
unlock("Api::V1::Issues::CreateService:#{project.id}") # 结束写数据,解锁
|
||||
end
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ class Api::V1::Issues::Journals::CreateService < ApplicationService
|
||||
|
||||
# @信息发送
|
||||
AtmeService.call(current_user, @atme_receivers, @created_journal) unless receivers_login.blank?
|
||||
TouchWebhookJob.perform_later('IssueComment', @issue&.id, @current_user.id, @created_journal.id)
|
||||
TouchWebhookJob.perform_later('IssueComment', @issue&.id, @current_user.id, @created_journal.id, 'created', {})
|
||||
unlock("Api::V1::Issues::Journals::CreateService:#{@issue.id}")
|
||||
|
||||
@created_journal
|
||||
|
||||
@@ -38,6 +38,7 @@ class Api::V1::Issues::Journals::UpdateService < ApplicationService
|
||||
|
||||
# @信息发送
|
||||
AtmeService.call(current_user, @atme_receivers, @created_journal) unless receivers_login.blank?
|
||||
TouchWebhookJob.perform_later('IssueComment', @issue&.id, @current_user.id, @updated_journal.id, 'edited', @updated_journal.previous_changes.stringify_keys)
|
||||
|
||||
unlock("Api::V1::Issues::Journals::UpdateService:#{@issue.id}:#{@journal.id}")
|
||||
|
||||
|
||||
@@ -78,9 +78,9 @@ class Api::V1::Issues::UpdateService < ApplicationService
|
||||
end
|
||||
|
||||
# 触发webhook
|
||||
TouchWebhookJob.perform_later('IssueCreate', @updated_issue&.id, current_user.id, previous_issue_changes)
|
||||
TouchWebhookJob.perform_later('IssueLabel', @updated_issue&.id, current_user.id, issue_tag_ids)
|
||||
TouchWebhookJob.perform_later('IssueAssign', @updated_issue&.id, current_user.id, assigner_ids)
|
||||
TouchWebhookJob.perform_later('IssueUpdate', @updated_issue&.id, current_user.id, previous_issue_changes.except(:issue_tags_value, :assigned_to_id))
|
||||
TouchWebhookJob.perform_later('IssueLabel', @updated_issue&.id, current_user.id, issue_tag_ids) unless issue_tag_ids.nil?
|
||||
TouchWebhookJob.perform_later('IssueAssign', @updated_issue&.id, current_user.id, assigner_ids) unless assigner_ids.nil?
|
||||
unlock("Api::V1::Issues::UpdateService:#{project.id}:#{issue.id}")
|
||||
|
||||
return @updated_issue
|
||||
|
||||
@@ -2,14 +2,16 @@ class Webhook::IssueCommentClient
|
||||
|
||||
include Webhook::Client
|
||||
|
||||
attr_accessor :webhook, :issue, :journal, :sender, :event
|
||||
attr_accessor :webhook, :issue, :journal, :sender, :event, :action_type, :comment_json
|
||||
|
||||
def initialize(webhook, issue, journal, sender, event)
|
||||
def initialize(webhook, issue, journal, sender, event, action_type, comment_json={})
|
||||
@webhook = webhook
|
||||
@issue = issue
|
||||
@journal = journal
|
||||
@sender = sender
|
||||
@event = event
|
||||
@action_type = action_type
|
||||
@comment_json = comment_json
|
||||
|
||||
# 构建client参数
|
||||
super({
|
||||
@@ -25,13 +27,19 @@ class Webhook::IssueCommentClient
|
||||
private
|
||||
|
||||
def payload_content
|
||||
{
|
||||
"action": "created",
|
||||
payload_content = {
|
||||
"action": @action_type,
|
||||
"issue": JSON.parse(@issue.to_builder.target!),
|
||||
"journal": JSON.parse(@journal.to_builder.target!),
|
||||
"journal": @journal.present? ? JSON.parse(@journal.to_builder.target!) : @comment_json,
|
||||
"project": JSON.parse(@issue.project.to_builder.target!),
|
||||
"sender": JSON.parse(@sender.to_builder.target!),
|
||||
"is_pull": false
|
||||
}
|
||||
|
||||
payload_content.merge!({
|
||||
"changes": @comment_json,
|
||||
}) if @action_type == "edited"
|
||||
|
||||
payload_content
|
||||
end
|
||||
end
|
||||
@@ -1,15 +1,16 @@
|
||||
class Webhook::PullCommentClient
|
||||
include Webhook::Client
|
||||
|
||||
attr_accessor :webhook, :pull, :journal, :sender, :event
|
||||
attr_accessor :webhook, :pull, :journal, :sender, :event, :action_type, :comment_json
|
||||
|
||||
def initialize(webhook, pull, journal, sender, event)
|
||||
def initialize(webhook, pull, journal, sender, event, action_type='created', comment_json={})
|
||||
@webhook = webhook
|
||||
@pull = pull
|
||||
@journal = journal
|
||||
@sender = sender
|
||||
@event = event
|
||||
|
||||
@action_type = action_type
|
||||
@comment_json = comment_json
|
||||
# 构建client参数
|
||||
super({
|
||||
uuid: SecureRandom.uuid,
|
||||
@@ -22,15 +23,21 @@ class Webhook::PullCommentClient
|
||||
private
|
||||
|
||||
def payload_content
|
||||
{
|
||||
"action": "created",
|
||||
payload_content = {
|
||||
"action": @action_type,
|
||||
"number": @pull.gitea_number,
|
||||
"pull_request": JSON.parse(@pull.to_builder.target!),
|
||||
"comment": JSON.parse(@journal.to_builder.target!),
|
||||
"comment": @journal.present? ? JSON.parse(@journal.to_builder.target!) : @comment_json,
|
||||
"project": JSON.parse(@pull.project.to_builder.target!),
|
||||
"sender": JSON.parse(@sender.to_builder.target!),
|
||||
"is_pull": true
|
||||
}
|
||||
|
||||
payload_content.merge!({
|
||||
"changes": @comment_json
|
||||
}) if @action_type == "edited"
|
||||
|
||||
payload_content
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user