discourse/app/serializers/admin_web_hook_serializer.rb
Sam Saffron 30990006a9 DEV: enable frozen string literal on all files
This reduces chances of errors where consumers of strings mutate inputs
and reduces memory usage of the app.

Test suite passes now, but there may be some stuff left, so we will run
a few sites on a branch prior to merging
2019-05-13 09:31:32 +08:00

26 lines
857 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: false
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