mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 11:20:57 -06:00
cead0cf684
Include categories when fetching admin/web_hooks and make 'extras' more useful. 'extras' is the mechanism we use to provide context for rest objects. However, previously: * When you fetched many objects, extras was only set on the ResultSet, not on each object, * If you need derived data from extras, there wasn't a sensible place to put this code. Now, you can create an 'ExtrasClass' static field on your rest model and this class will be used for your extras data,
31 lines
911 B
Ruby
31 lines
911 B
Ruby
# frozen_string_literal: true
|
|
|
|
class AdminWebHookSerializer < ApplicationSerializer
|
|
attributes :id,
|
|
:payload_url,
|
|
:content_type,
|
|
:last_delivery_status,
|
|
:secret,
|
|
:wildcard_web_hook,
|
|
:verify_certificate,
|
|
:active,
|
|
:web_hook_event_types
|
|
|
|
has_many :categories, serializer: BasicCategorySerializer, embed: :ids, include: true
|
|
has_many :tags,
|
|
key: :tag_names,
|
|
serializer: TagSerializer,
|
|
embed: :ids,
|
|
embed_key: :name,
|
|
include: false
|
|
has_many :groups, serializer: BasicGroupSerializer, embed: :ids, include: false
|
|
|
|
def web_hook_event_types
|
|
ActiveModel::ArraySerializer.new(object.web_hook_event_types).as_json
|
|
end
|
|
|
|
def last_delivery_status
|
|
object.active ? object.last_delivery_status : WebHook.last_delivery_statuses[:disabled]
|
|
end
|
|
end
|