Add administrative webhooks (#18510)
* Add administrative webhooks * Fix error when webhook is deleted before delivery worker runs
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::Admin::ReportSerializer < ActiveModel::Serializer
|
||||
attributes :id, :action_taken, :category, :comment, :created_at, :updated_at
|
||||
attributes :id, :action_taken, :action_taken_at, :category, :comment,
|
||||
:created_at, :updated_at
|
||||
|
||||
has_one :account, serializer: REST::Admin::AccountSerializer
|
||||
has_one :target_account, serializer: REST::Admin::AccountSerializer
|
||||
|
26
app/serializers/rest/admin/webhook_event_serializer.rb
Normal file
26
app/serializers/rest/admin/webhook_event_serializer.rb
Normal file
@ -0,0 +1,26 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::Admin::WebhookEventSerializer < ActiveModel::Serializer
|
||||
def self.serializer_for(model, options)
|
||||
case model.class.name
|
||||
when 'Account'
|
||||
REST::Admin::AccountSerializer
|
||||
when 'Report'
|
||||
REST::Admin::ReportSerializer
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
attributes :event, :created_at
|
||||
|
||||
has_one :virtual_object, key: :object
|
||||
|
||||
def virtual_object
|
||||
object.object
|
||||
end
|
||||
|
||||
def event
|
||||
object.type
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user