Refactor JSON templates to be generated with ActiveModelSerializers instead of Rabl (#4090)
This commit is contained in:
@ -1,2 +0,0 @@
|
||||
collection @accounts
|
||||
extends 'api/v1/accounts/show'
|
@ -1,9 +0,0 @@
|
||||
object @account
|
||||
|
||||
attribute :id
|
||||
node(:following) { |account| @following[account.id] || false }
|
||||
node(:followed_by) { |account| @followed_by[account.id] || false }
|
||||
node(:blocking) { |account| @blocking[account.id] || false }
|
||||
node(:muting) { |account| @muting[account.id] || false }
|
||||
node(:requested) { |account| @requested[account.id] || false }
|
||||
node(:domain_blocking) { |account| @domain_blocking[account.id] || false }
|
@ -1,2 +0,0 @@
|
||||
collection @accounts
|
||||
extends 'api/v1/accounts/relationship'
|
@ -1,12 +0,0 @@
|
||||
object @account
|
||||
|
||||
attributes :id, :username, :acct, :display_name, :locked, :created_at
|
||||
|
||||
node(:note) { |account| Formatter.instance.simplified_format(account) }
|
||||
node(:url) { |account| TagManager.instance.url_for(account) }
|
||||
node(:avatar) { |account| full_asset_url(account.avatar_original_url) }
|
||||
node(:avatar_static) { |account| full_asset_url(account.avatar_static_url) }
|
||||
node(:header) { |account| full_asset_url(account.header_original_url) }
|
||||
node(:header_static) { |account| full_asset_url(account.header_static_url) }
|
||||
|
||||
attributes :followers_count, :following_count, :statuses_count
|
@ -1,2 +0,0 @@
|
||||
collection @statuses
|
||||
extends 'api/v1/statuses/show'
|
@ -1,4 +0,0 @@
|
||||
object @app
|
||||
attributes :id, :redirect_uri
|
||||
node(:client_id) { |app| app.uid }
|
||||
node(:client_secret) { |app| app.secret }
|
@ -1,3 +0,0 @@
|
||||
object @application
|
||||
|
||||
attributes :name, :website
|
@ -1,2 +0,0 @@
|
||||
collection @accounts
|
||||
extends 'api/v1/accounts/show'
|
@ -1,2 +0,0 @@
|
||||
collection @statuses
|
||||
extends 'api/v1/statuses/show'
|
@ -1,2 +0,0 @@
|
||||
collection @accounts
|
||||
extends 'api/v1/accounts/show'
|
@ -1,2 +0,0 @@
|
||||
object @account
|
||||
extends('api/v1/accounts/show')
|
@ -1,10 +0,0 @@
|
||||
object false
|
||||
|
||||
node(:uri) { site_hostname }
|
||||
node(:title) { Setting.site_title }
|
||||
node(:description) { Setting.site_description }
|
||||
node(:email) { Setting.site_contact_email }
|
||||
node(:version) { Mastodon::Version.to_s }
|
||||
node :urls do
|
||||
{ :streaming_api => Rails.configuration.x.streaming_api_base_url }
|
||||
end
|
@ -1,7 +0,0 @@
|
||||
object @media
|
||||
attribute :id, :type
|
||||
|
||||
node(:url) { |media| full_asset_url(media.file.url(:original)) }
|
||||
node(:preview_url) { |media| full_asset_url(media.file.url(:small)) }
|
||||
node(:text_url) { |media| medium_url(media) }
|
||||
node(:meta) { |media| media.file.meta }
|
@ -1,2 +0,0 @@
|
||||
collection @accounts
|
||||
extends 'api/v1/accounts/show'
|
@ -1,2 +0,0 @@
|
||||
collection @notifications
|
||||
extends 'api/v1/notifications/show'
|
@ -1,11 +0,0 @@
|
||||
object @notification
|
||||
|
||||
attributes :id, :type, :created_at
|
||||
|
||||
child from_account: :account do
|
||||
extends 'api/v1/accounts/show'
|
||||
end
|
||||
|
||||
node(:status, if: lambda { |n| [:favourite, :reblog, :mention].include?(n.type) }) do |n|
|
||||
partial 'api/v1/statuses/show', object: n.target_status
|
||||
end
|
@ -1,2 +0,0 @@
|
||||
collection @reports
|
||||
extends 'api/v1/reports/show'
|
@ -1,2 +0,0 @@
|
||||
object @report
|
||||
attributes :id, :action_taken
|
@ -1,13 +0,0 @@
|
||||
object @search
|
||||
|
||||
child :accounts, object_root: false do
|
||||
extends 'api/v1/accounts/show'
|
||||
end
|
||||
|
||||
node(:hashtags) do |search|
|
||||
search.hashtags.map(&:name)
|
||||
end
|
||||
|
||||
child :statuses, object_root: false do
|
||||
extends 'api/v1/statuses/show'
|
||||
end
|
@ -1,6 +0,0 @@
|
||||
attributes :id, :remote_url, :type
|
||||
|
||||
node(:url) { |media| full_asset_url(media.file.url(:original)) }
|
||||
node(:preview_url) { |media| full_asset_url(media.file.url(:small)) }
|
||||
node(:text_url) { |media| media.local? ? medium_url(media) : nil }
|
||||
node(:meta) { |media| media.file.meta }
|
@ -1,4 +0,0 @@
|
||||
node(:url) { |mention| TagManager.instance.url_for(mention.account) }
|
||||
node(:acct) { |mention| mention.account_acct }
|
||||
node(:id) { |mention| mention.account_id }
|
||||
node(:username) { |mention| mention.account_username }
|
@ -1,29 +0,0 @@
|
||||
attributes :id, :created_at, :in_reply_to_id,
|
||||
:in_reply_to_account_id, :sensitive,
|
||||
:spoiler_text, :visibility, :language
|
||||
|
||||
node(:uri) { |status| TagManager.instance.uri_for(status) }
|
||||
node(:content) { |status| Formatter.instance.format(status) }
|
||||
node(:url) { |status| TagManager.instance.url_for(status) }
|
||||
node(:reblogs_count) { |status| defined?(@reblogs_counts_map) ? (@reblogs_counts_map[status.id] || 0) : status.reblogs_count }
|
||||
node(:favourites_count) { |status| defined?(@favourites_counts_map) ? (@favourites_counts_map[status.id] || 0) : status.favourites_count }
|
||||
|
||||
child :application do
|
||||
extends 'api/v1/apps/show'
|
||||
end
|
||||
|
||||
child :account do
|
||||
extends 'api/v1/accounts/show'
|
||||
end
|
||||
|
||||
child :media_attachments, object_root: false do
|
||||
extends 'api/v1/statuses/_media'
|
||||
end
|
||||
|
||||
child :mentions, object_root: false do
|
||||
extends 'api/v1/statuses/_mention'
|
||||
end
|
||||
|
||||
child :tags, object_root: false do
|
||||
extends 'api/v1/statuses/_tags'
|
||||
end
|
@ -1,2 +0,0 @@
|
||||
attribute :name
|
||||
node(:url) { |tag| tag_url(tag) }
|
@ -1,2 +0,0 @@
|
||||
collection @accounts
|
||||
extends 'api/v1/accounts/show'
|
@ -1,7 +0,0 @@
|
||||
object @card
|
||||
|
||||
attributes :url, :title, :description, :type,
|
||||
:author_name, :author_url, :provider_name,
|
||||
:provider_url, :html, :width, :height
|
||||
|
||||
node(:image) { |card| card.image? ? full_asset_url(card.image.url(:original)) : nil }
|
@ -1,9 +0,0 @@
|
||||
object @context
|
||||
|
||||
node :ancestors do |context|
|
||||
partial 'api/v1/statuses/index', object: context.ancestors
|
||||
end
|
||||
|
||||
node :descendants do |context|
|
||||
partial 'api/v1/statuses/index', object: context.descendants
|
||||
end
|
@ -1,2 +0,0 @@
|
||||
collection @statuses
|
||||
extends('api/v1/statuses/show')
|
@ -1,15 +0,0 @@
|
||||
object @status
|
||||
|
||||
extends 'api/v1/statuses/_show'
|
||||
|
||||
node(:favourited, if: proc { !current_account.nil? }) { |status| defined?(@favourites_map) ? @favourites_map[status.id] : current_account.favourited?(status) }
|
||||
node(:reblogged, if: proc { !current_account.nil? }) { |status| defined?(@reblogs_map) ? @reblogs_map[status.id] : current_account.reblogged?(status) }
|
||||
node(:muted, if: proc { !current_account.nil? }) { |status| defined?(@mutes_map) ? @mutes_map[status.conversation_id] : current_account.muting_conversation?(status.conversation) }
|
||||
|
||||
child reblog: :reblog do
|
||||
extends 'api/v1/statuses/_show'
|
||||
|
||||
node(:favourited, if: proc { !current_account.nil? }) { |status| defined?(@favourites_map) ? @favourites_map[status.id] : current_account.favourited?(status) }
|
||||
node(:reblogged, if: proc { !current_account.nil? }) { |status| defined?(@reblogs_map) ? @reblogs_map[status.id] : current_account.reblogged?(status) }
|
||||
node(:muted, if: proc { !current_account.nil? }) { false }
|
||||
end
|
@ -1,2 +0,0 @@
|
||||
collection @statuses
|
||||
extends('api/v1/statuses/show')
|
@ -24,8 +24,8 @@ end
|
||||
|
||||
node(:accounts) do
|
||||
store = {}
|
||||
store[current_account.id] = partial('api/v1/accounts/show', object: current_account)
|
||||
store[@admin.id] = partial('api/v1/accounts/show', object: @admin) unless @admin.nil?
|
||||
store[current_account.id] = ActiveModelSerializers::SerializableResource.new(current_account, serializer: REST::AccountSerializer)
|
||||
store[@admin.id] = ActiveModelSerializers::SerializableResource.new(@admin, serializer: REST::AccountSerializer) unless @admin.nil?
|
||||
store
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user