about summary refs log tree commit diff
path: root/app/models/status.rb
diff options
context:
space:
mode:
authorVyr Cossont <VyrCossont@users.noreply.github.com>2023-03-18 23:47:54 -0700
committerGitHub <noreply@github.com>2023-03-19 07:47:54 +0100
commit94cbd808b5b3e7999c7e77dc724b7e8c9dd2bdec (patch)
tree8d99247a5d64a38a3ce45eb20f9dc75b74a6f492 /app/models/status.rb
parent34096bc6ea788fece267116ef190e0d218f77b18 (diff)
Webhooks for local status.create, status.update, account.update (#24133)
Diffstat (limited to 'app/models/status.rb')
-rw-r--r--app/models/status.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index e7ea191a8..2e32c3f16 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -111,6 +111,9 @@ class Status < ApplicationRecord
     where('NOT EXISTS (SELECT * FROM statuses_tags forbidden WHERE forbidden.status_id = statuses.id AND forbidden.tag_id IN (?))', tag_ids)
   }
 
+  after_create_commit :trigger_create_webhooks
+  after_update_commit :trigger_update_webhooks
+
   cache_associated :application,
                    :media_attachments,
                    :conversation,
@@ -535,4 +538,12 @@ class Status < ApplicationRecord
     reblog&.decrement_count!(:reblogs_count) if reblog?
     thread&.decrement_count!(:replies_count) if in_reply_to_id.present? && distributable?
   end
+
+  def trigger_create_webhooks
+    TriggerWebhookWorker.perform_async('status.created', 'Status', id) if local?
+  end
+
+  def trigger_update_webhooks
+    TriggerWebhookWorker.perform_async('status.updated', 'Status', id) if local?
+  end
 end