Gab Social. All are welcome.
This commit is contained in:
54
app/serializers/rest/account_serializer.rb
Normal file
54
app/serializers/rest/account_serializer.rb
Normal file
@@ -0,0 +1,54 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::AccountSerializer < ActiveModel::Serializer
|
||||
include RoutingHelper
|
||||
|
||||
attributes :id, :username, :acct, :display_name, :locked, :bot, :created_at,
|
||||
:note, :url, :avatar, :avatar_static, :header, :header_static,
|
||||
:followers_count, :following_count, :statuses_count, :is_pro, :is_verified
|
||||
|
||||
has_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved_and_not_nested?
|
||||
has_many :emojis, serializer: REST::CustomEmojiSerializer
|
||||
|
||||
class FieldSerializer < ActiveModel::Serializer
|
||||
attributes :name, :value, :verified_at
|
||||
|
||||
def value
|
||||
Formatter.instance.format_field(object.account, object.value)
|
||||
end
|
||||
end
|
||||
|
||||
has_many :fields
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
|
||||
def note
|
||||
Formatter.instance.simplified_format(object)
|
||||
end
|
||||
|
||||
def url
|
||||
TagManager.instance.url_for(object)
|
||||
end
|
||||
|
||||
def avatar
|
||||
full_asset_url(object.avatar_original_url)
|
||||
end
|
||||
|
||||
def avatar_static
|
||||
full_asset_url(object.avatar_static_url)
|
||||
end
|
||||
|
||||
def header
|
||||
full_asset_url(object.header_original_url)
|
||||
end
|
||||
|
||||
def header_static
|
||||
full_asset_url(object.header_static_url)
|
||||
end
|
||||
|
||||
def moved_and_not_nested?
|
||||
object.moved? && object.moved_to_account.moved_to_account_id.nil?
|
||||
end
|
||||
end
|
||||
26
app/serializers/rest/application_serializer.rb
Normal file
26
app/serializers/rest/application_serializer.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::ApplicationSerializer < ActiveModel::Serializer
|
||||
attributes :id, :name, :website, :redirect_uri,
|
||||
:client_id, :client_secret, :vapid_key
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
|
||||
def client_id
|
||||
object.uid
|
||||
end
|
||||
|
||||
def client_secret
|
||||
object.secret
|
||||
end
|
||||
|
||||
def website
|
||||
object.website.presence
|
||||
end
|
||||
|
||||
def vapid_key
|
||||
Rails.configuration.x.vapid_public_key
|
||||
end
|
||||
end
|
||||
6
app/serializers/rest/context_serializer.rb
Normal file
6
app/serializers/rest/context_serializer.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::ContextSerializer < ActiveModel::Serializer
|
||||
has_many :ancestors, serializer: REST::StatusSerializer
|
||||
has_many :descendants, serializer: REST::StatusSerializer
|
||||
end
|
||||
12
app/serializers/rest/conversation_serializer.rb
Normal file
12
app/serializers/rest/conversation_serializer.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::ConversationSerializer < ActiveModel::Serializer
|
||||
attributes :id, :unread
|
||||
|
||||
has_many :participant_accounts, key: :accounts, serializer: REST::AccountSerializer
|
||||
has_one :last_status, serializer: REST::StatusSerializer
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
end
|
||||
17
app/serializers/rest/credential_account_serializer.rb
Normal file
17
app/serializers/rest/credential_account_serializer.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::CredentialAccountSerializer < REST::AccountSerializer
|
||||
attributes :source
|
||||
|
||||
def source
|
||||
user = object.user
|
||||
|
||||
{
|
||||
privacy: user.setting_default_privacy,
|
||||
sensitive: user.setting_default_sensitive,
|
||||
language: user.setting_default_language,
|
||||
note: object.note,
|
||||
fields: object.fields.map(&:to_h),
|
||||
}
|
||||
end
|
||||
end
|
||||
15
app/serializers/rest/custom_emoji_serializer.rb
Normal file
15
app/serializers/rest/custom_emoji_serializer.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::CustomEmojiSerializer < ActiveModel::Serializer
|
||||
include RoutingHelper
|
||||
|
||||
attributes :shortcode, :url, :static_url, :visible_in_picker
|
||||
|
||||
def url
|
||||
full_asset_url(object.image.url)
|
||||
end
|
||||
|
||||
def static_url
|
||||
full_asset_url(object.image.url(:static))
|
||||
end
|
||||
end
|
||||
10
app/serializers/rest/filter_serializer.rb
Normal file
10
app/serializers/rest/filter_serializer.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::FilterSerializer < ActiveModel::Serializer
|
||||
attributes :id, :phrase, :context, :whole_word, :expires_at,
|
||||
:irreversible
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
end
|
||||
17
app/serializers/rest/group_relationship_serializer.rb
Normal file
17
app/serializers/rest/group_relationship_serializer.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::GroupRelationshipSerializer < ActiveModel::Serializer
|
||||
attributes :id, :member, :admin
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
|
||||
def member
|
||||
instance_options[:relationships].member[object.id] ? true : false
|
||||
end
|
||||
|
||||
def admin
|
||||
instance_options[:relationships].admin[object.id] ? true : false
|
||||
end
|
||||
end
|
||||
15
app/serializers/rest/group_serializer.rb
Normal file
15
app/serializers/rest/group_serializer.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::GroupSerializer < ActiveModel::Serializer
|
||||
include RoutingHelper
|
||||
|
||||
attributes :id, :title, :description, :cover_image_url, :is_archived
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
|
||||
def cover_image_url
|
||||
full_asset_url(object.cover_image.url)
|
||||
end
|
||||
end
|
||||
17
app/serializers/rest/identity_proof_serializer.rb
Normal file
17
app/serializers/rest/identity_proof_serializer.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::IdentityProofSerializer < ActiveModel::Serializer
|
||||
attributes :provider, :provider_username, :updated_at, :proof_url, :profile_url
|
||||
|
||||
def proof_url
|
||||
object.badge.proof_url
|
||||
end
|
||||
|
||||
def profile_url
|
||||
object.badge.profile_url
|
||||
end
|
||||
|
||||
def provider
|
||||
object.provider.capitalize
|
||||
end
|
||||
end
|
||||
63
app/serializers/rest/instance_serializer.rb
Normal file
63
app/serializers/rest/instance_serializer.rb
Normal file
@@ -0,0 +1,63 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::InstanceSerializer < ActiveModel::Serializer
|
||||
include RoutingHelper
|
||||
|
||||
attributes :uri, :title, :description, :email,
|
||||
:version, :urls, :stats, :thumbnail,
|
||||
:languages, :registrations
|
||||
|
||||
has_one :contact_account, serializer: REST::AccountSerializer
|
||||
|
||||
delegate :contact_account, to: :instance_presenter
|
||||
|
||||
def uri
|
||||
Rails.configuration.x.local_domain
|
||||
end
|
||||
|
||||
def title
|
||||
Setting.site_title
|
||||
end
|
||||
|
||||
def description
|
||||
Setting.site_description
|
||||
end
|
||||
|
||||
def email
|
||||
Setting.site_contact_email
|
||||
end
|
||||
|
||||
def version
|
||||
GabSocial::Version.to_s
|
||||
end
|
||||
|
||||
def thumbnail
|
||||
instance_presenter.thumbnail ? full_asset_url(instance_presenter.thumbnail.file.url) : full_pack_url('media/images/preview.jpg')
|
||||
end
|
||||
|
||||
def stats
|
||||
{
|
||||
user_count: instance_presenter.user_count,
|
||||
status_count: instance_presenter.status_count,
|
||||
domain_count: instance_presenter.domain_count,
|
||||
}
|
||||
end
|
||||
|
||||
def urls
|
||||
{ streaming_api: Rails.configuration.x.streaming_api_base_url }
|
||||
end
|
||||
|
||||
def languages
|
||||
[I18n.default_locale]
|
||||
end
|
||||
|
||||
def registrations
|
||||
Setting.registrations_mode != 'none' && !Rails.configuration.x.single_user_mode
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def instance_presenter
|
||||
@instance_presenter ||= InstancePresenter.new
|
||||
end
|
||||
end
|
||||
9
app/serializers/rest/list_serializer.rb
Normal file
9
app/serializers/rest/list_serializer.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::ListSerializer < ActiveModel::Serializer
|
||||
attributes :id, :title
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
end
|
||||
41
app/serializers/rest/media_attachment_serializer.rb
Normal file
41
app/serializers/rest/media_attachment_serializer.rb
Normal file
@@ -0,0 +1,41 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::MediaAttachmentSerializer < ActiveModel::Serializer
|
||||
include RoutingHelper
|
||||
|
||||
attributes :id, :type, :url, :preview_url,
|
||||
:remote_url, :text_url, :meta,
|
||||
:description, :blurhash
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
|
||||
def url
|
||||
if object.needs_redownload?
|
||||
media_proxy_url(object.id, :original)
|
||||
else
|
||||
full_asset_url(object.file.url(:original))
|
||||
end
|
||||
end
|
||||
|
||||
def remote_url
|
||||
object.remote_url.presence
|
||||
end
|
||||
|
||||
def preview_url
|
||||
if object.needs_redownload?
|
||||
media_proxy_url(object.id, :small)
|
||||
else
|
||||
full_asset_url(object.file.url(:small))
|
||||
end
|
||||
end
|
||||
|
||||
def text_url
|
||||
object.local? ? medium_url(object) : nil
|
||||
end
|
||||
|
||||
def meta
|
||||
object.file.meta
|
||||
end
|
||||
end
|
||||
16
app/serializers/rest/notification_serializer.rb
Normal file
16
app/serializers/rest/notification_serializer.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::NotificationSerializer < ActiveModel::Serializer
|
||||
attributes :id, :type, :created_at
|
||||
|
||||
belongs_to :from_account, key: :account, serializer: REST::AccountSerializer
|
||||
belongs_to :target_status, key: :status, if: :status_type?, serializer: REST::StatusSerializer
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
|
||||
def status_type?
|
||||
[:favourite, :reblog, :mention, :poll].include?(object.type)
|
||||
end
|
||||
end
|
||||
31
app/serializers/rest/poll_serializer.rb
Normal file
31
app/serializers/rest/poll_serializer.rb
Normal file
@@ -0,0 +1,31 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::PollSerializer < ActiveModel::Serializer
|
||||
attributes :id, :expires_at, :expired,
|
||||
:multiple, :votes_count
|
||||
|
||||
has_many :loaded_options, key: :options
|
||||
has_many :emojis, serializer: REST::CustomEmojiSerializer
|
||||
|
||||
attribute :voted, if: :current_user?
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
|
||||
def expired
|
||||
object.expired?
|
||||
end
|
||||
|
||||
def voted
|
||||
object.voted?(current_user.account)
|
||||
end
|
||||
|
||||
def current_user?
|
||||
!current_user.nil?
|
||||
end
|
||||
|
||||
class OptionSerializer < ActiveModel::Serializer
|
||||
attributes :title, :votes_count
|
||||
end
|
||||
end
|
||||
30
app/serializers/rest/preferences_serializer.rb
Normal file
30
app/serializers/rest/preferences_serializer.rb
Normal file
@@ -0,0 +1,30 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::PreferencesSerializer < ActiveModel::Serializer
|
||||
attribute :posting_default_privacy, key: 'posting:default:visibility'
|
||||
attribute :posting_default_sensitive, key: 'posting:default:sensitive'
|
||||
attribute :posting_default_language, key: 'posting:default:language'
|
||||
|
||||
attribute :reading_default_sensitive_media, key: 'reading:expand:media'
|
||||
attribute :reading_default_sensitive_text, key: 'reading:expand:spoilers'
|
||||
|
||||
def posting_default_privacy
|
||||
object.user.setting_default_privacy
|
||||
end
|
||||
|
||||
def posting_default_sensitive
|
||||
object.user.setting_default_sensitive
|
||||
end
|
||||
|
||||
def posting_default_language
|
||||
object.user.setting_default_language.presence
|
||||
end
|
||||
|
||||
def reading_default_sensitive_media
|
||||
object.user.setting_display_media
|
||||
end
|
||||
|
||||
def reading_default_sensitive_text
|
||||
object.user.setting_expand_spoilers
|
||||
end
|
||||
end
|
||||
14
app/serializers/rest/preview_card_serializer.rb
Normal file
14
app/serializers/rest/preview_card_serializer.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::PreviewCardSerializer < ActiveModel::Serializer
|
||||
include RoutingHelper
|
||||
|
||||
attributes :url, :title, :description, :type,
|
||||
:author_name, :author_url, :provider_name,
|
||||
:provider_url, :html, :width, :height,
|
||||
:image, :embed_url
|
||||
|
||||
def image
|
||||
object.image? ? full_asset_url(object.image.url(:original)) : nil
|
||||
end
|
||||
end
|
||||
53
app/serializers/rest/relationship_serializer.rb
Normal file
53
app/serializers/rest/relationship_serializer.rb
Normal file
@@ -0,0 +1,53 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::RelationshipSerializer < ActiveModel::Serializer
|
||||
attributes :id, :following, :showing_reblogs, :followed_by, :blocking, :blocked_by,
|
||||
:muting, :muting_notifications, :requested, :domain_blocking,
|
||||
:endorsed
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
|
||||
def following
|
||||
instance_options[:relationships].following[object.id] ? true : false
|
||||
end
|
||||
|
||||
def showing_reblogs
|
||||
(instance_options[:relationships].following[object.id] || {})[:reblogs] ||
|
||||
(instance_options[:relationships].requested[object.id] || {})[:reblogs] ||
|
||||
false
|
||||
end
|
||||
|
||||
def followed_by
|
||||
instance_options[:relationships].followed_by[object.id] || false
|
||||
end
|
||||
|
||||
def blocking
|
||||
instance_options[:relationships].blocking[object.id] || false
|
||||
end
|
||||
|
||||
def blocked_by
|
||||
instance_options[:relationships].blocked_by[object.id] || false
|
||||
end
|
||||
|
||||
def muting
|
||||
instance_options[:relationships].muting[object.id] ? true : false
|
||||
end
|
||||
|
||||
def muting_notifications
|
||||
(instance_options[:relationships].muting[object.id] || {})[:notifications] || false
|
||||
end
|
||||
|
||||
def requested
|
||||
instance_options[:relationships].requested[object.id] ? true : false
|
||||
end
|
||||
|
||||
def domain_blocking
|
||||
instance_options[:relationships].domain_blocking[object.id] || false
|
||||
end
|
||||
|
||||
def endorsed
|
||||
instance_options[:relationships].endorsed[object.id] || false
|
||||
end
|
||||
end
|
||||
9
app/serializers/rest/report_serializer.rb
Normal file
9
app/serializers/rest/report_serializer.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::ReportSerializer < ActiveModel::Serializer
|
||||
attributes :id, :action_taken
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
end
|
||||
15
app/serializers/rest/scheduled_status_serializer.rb
Normal file
15
app/serializers/rest/scheduled_status_serializer.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::ScheduledStatusSerializer < ActiveModel::Serializer
|
||||
attributes :id, :scheduled_at, :params
|
||||
|
||||
has_many :media_attachments, serializer: REST::MediaAttachmentSerializer
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
|
||||
def params
|
||||
object.params.without(:application_id)
|
||||
end
|
||||
end
|
||||
12
app/serializers/rest/search_serializer.rb
Normal file
12
app/serializers/rest/search_serializer.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::SearchSerializer < ActiveModel::Serializer
|
||||
attributes :hashtags
|
||||
|
||||
has_many :accounts, serializer: REST::AccountSerializer
|
||||
has_many :statuses, serializer: REST::StatusSerializer
|
||||
|
||||
def hashtags
|
||||
object.hashtags.map(&:name)
|
||||
end
|
||||
end
|
||||
152
app/serializers/rest/status_serializer.rb
Normal file
152
app/serializers/rest/status_serializer.rb
Normal file
@@ -0,0 +1,152 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::StatusSerializer < ActiveModel::Serializer
|
||||
attributes :id, :created_at, :in_reply_to_id, :in_reply_to_account_id,
|
||||
:sensitive, :spoiler_text, :visibility, :language,
|
||||
:uri, :url, :replies_count, :reblogs_count,
|
||||
:favourites_count
|
||||
|
||||
attribute :favourited, if: :current_user?
|
||||
attribute :reblogged, if: :current_user?
|
||||
attribute :muted, if: :current_user?
|
||||
attribute :pinned, if: :pinnable?
|
||||
|
||||
attribute :content, unless: :source_requested?
|
||||
attribute :text, if: :source_requested?
|
||||
|
||||
belongs_to :reblog, serializer: REST::StatusSerializer
|
||||
belongs_to :application, if: :show_application?
|
||||
belongs_to :account, serializer: REST::AccountSerializer
|
||||
|
||||
has_many :media_attachments, serializer: REST::MediaAttachmentSerializer
|
||||
has_many :ordered_mentions, key: :mentions
|
||||
has_many :tags
|
||||
has_many :emojis, serializer: REST::CustomEmojiSerializer
|
||||
|
||||
has_one :preview_card, key: :card, serializer: REST::PreviewCardSerializer
|
||||
has_one :preloadable_poll, key: :poll, serializer: REST::PollSerializer
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
|
||||
def in_reply_to_id
|
||||
object.in_reply_to_id&.to_s
|
||||
end
|
||||
|
||||
def in_reply_to_account_id
|
||||
object.in_reply_to_account_id&.to_s
|
||||
end
|
||||
|
||||
def current_user?
|
||||
!current_user.nil?
|
||||
end
|
||||
|
||||
def show_application?
|
||||
object.account.user_shows_application? || (current_user? && current_user.account_id == object.account_id)
|
||||
end
|
||||
|
||||
def visibility
|
||||
# This visibility is masked behind "private"
|
||||
# to avoid API changes because there are no
|
||||
# UX differences
|
||||
if object.limited_visibility?
|
||||
'private'
|
||||
else
|
||||
object.visibility
|
||||
end
|
||||
end
|
||||
|
||||
def uri
|
||||
OStatus::TagManager.instance.uri_for(object)
|
||||
end
|
||||
|
||||
def content
|
||||
Formatter.instance.format(object)
|
||||
end
|
||||
|
||||
def url
|
||||
TagManager.instance.url_for(object)
|
||||
end
|
||||
|
||||
def favourited
|
||||
if instance_options && instance_options[:relationships]
|
||||
instance_options[:relationships].favourites_map[object.id] || false
|
||||
else
|
||||
current_user.account.favourited?(object)
|
||||
end
|
||||
end
|
||||
|
||||
def reblogged
|
||||
if instance_options && instance_options[:relationships]
|
||||
instance_options[:relationships].reblogs_map[object.id] || false
|
||||
else
|
||||
current_user.account.reblogged?(object)
|
||||
end
|
||||
end
|
||||
|
||||
def muted
|
||||
if instance_options && instance_options[:relationships]
|
||||
instance_options[:relationships].mutes_map[object.conversation_id] || false
|
||||
else
|
||||
current_user.account.muting_conversation?(object.conversation)
|
||||
end
|
||||
end
|
||||
|
||||
def pinned
|
||||
if instance_options && instance_options[:relationships]
|
||||
instance_options[:relationships].pins_map[object.id] || false
|
||||
else
|
||||
current_user.account.pinned?(object)
|
||||
end
|
||||
end
|
||||
|
||||
def pinnable?
|
||||
current_user? &&
|
||||
current_user.account_id == object.account_id &&
|
||||
!object.reblog? &&
|
||||
%w(public unlisted).include?(object.visibility)
|
||||
end
|
||||
|
||||
def source_requested?
|
||||
instance_options[:source_requested]
|
||||
end
|
||||
|
||||
def ordered_mentions
|
||||
object.active_mentions.to_a.sort_by(&:id)
|
||||
end
|
||||
|
||||
class ApplicationSerializer < ActiveModel::Serializer
|
||||
attributes :name, :website
|
||||
end
|
||||
|
||||
class MentionSerializer < ActiveModel::Serializer
|
||||
attributes :id, :username, :url, :acct
|
||||
|
||||
def id
|
||||
object.account_id.to_s
|
||||
end
|
||||
|
||||
def username
|
||||
object.account_username
|
||||
end
|
||||
|
||||
def url
|
||||
TagManager.instance.url_for(object.account)
|
||||
end
|
||||
|
||||
def acct
|
||||
object.account_acct
|
||||
end
|
||||
end
|
||||
|
||||
class TagSerializer < ActiveModel::Serializer
|
||||
include RoutingHelper
|
||||
|
||||
attributes :name, :url
|
||||
|
||||
def url
|
||||
tag_url(object)
|
||||
end
|
||||
end
|
||||
end
|
||||
11
app/serializers/rest/tag_serializer.rb
Normal file
11
app/serializers/rest/tag_serializer.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::TagSerializer < ActiveModel::Serializer
|
||||
include RoutingHelper
|
||||
|
||||
attributes :name, :url, :history
|
||||
|
||||
def url
|
||||
tag_url(object)
|
||||
end
|
||||
end
|
||||
7
app/serializers/rest/v2/search_serializer.rb
Normal file
7
app/serializers/rest/v2/search_serializer.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::V2::SearchSerializer < ActiveModel::Serializer
|
||||
has_many :accounts, serializer: REST::AccountSerializer
|
||||
has_many :statuses, serializer: REST::StatusSerializer
|
||||
has_many :hashtags, serializer: REST::TagSerializer
|
||||
end
|
||||
13
app/serializers/rest/web_push_subscription_serializer.rb
Normal file
13
app/serializers/rest/web_push_subscription_serializer.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::WebPushSubscriptionSerializer < ActiveModel::Serializer
|
||||
attributes :id, :endpoint, :alerts, :server_key
|
||||
|
||||
def alerts
|
||||
object.data&.dig('alerts') || {}
|
||||
end
|
||||
|
||||
def server_key
|
||||
Rails.configuration.x.vapid_public_key
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user