Browse Source

fix: webhook tasks list error delay

tags/v4.0.0^2
yystopf 4 years ago
parent
commit
84f12adce8
2 changed files with 8 additions and 2 deletions
  1. +6
    -1
      app/models/gitea/webhook_task.rb
  2. +2
    -1
      app/views/projects/webhooks/tasks.json.jbuilder

+ 6
- 1
app/models/gitea/webhook_task.rb View File

@@ -1,7 +1,6 @@
class Gitea::WebhookTask < Gitea::Base
serialize :payload_content, JSON
serialize :request_content, JSON
serialize :response_content, JSON

self.inheritance_column = nil

@@ -10,4 +9,10 @@ class Gitea::WebhookTask < Gitea::Base
belongs_to :webhook, class_name: "Gitea::Webhook", foreign_key: :hook_id

enum type: {gogs: 1, slack: 2, gitea: 3, discord: 4, dingtalk: 5, telegram: 6, msteams: 7, feishu: 8, matrix: 9}

def response_content_json
JSON.parse(response_content)
rescue
{}
end
end

+ 2
- 1
app/views/projects/webhooks/tasks.json.jbuilder View File

@@ -1,5 +1,6 @@
json.total_count @tasks.total_count
json.tasks @tasks.each do |task|
json.(task, :id, :type, :uuid, :is_succeed, :is_delivered, :payload_content, :request_content, :response_content)
json.(task, :id, :event_type, :type, :uuid, :is_succeed, :is_delivered, :payload_content, :request_content)
json.response_content task.response_content_json
json.delivered_time Time.at(task.delivered*10**-9).strftime("%Y-%m-%d %H:%M:%S")
end

Loading…
Cancel
Save