1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00

Add icon field to instance endpoint

As we now allow admins to customize their app icon, it may be useful to expose it so apps can use it in the UI.

This is using the Android icons as they provide a good range of sizes.
This commit is contained in:
Renaud Chaput 2024-05-07 11:42:10 +02:00
parent 43bbdea421
commit 752fe1731e
No known key found for this signature in database
GPG key ID: BCFC859D49B46990

View file

@ -7,10 +7,12 @@ class REST::InstanceSerializer < ActiveModel::Serializer
has_one :account, serializer: REST::AccountSerializer
end
include InstanceHelper
include ApplicationHelper
include RoutingHelper
attributes :domain, :title, :version, :source_url, :description,
:usage, :thumbnail, :languages, :configuration,
:usage, :thumbnail, :icon, :languages, :configuration,
:registrations
has_one :contact, serializer: ContactSerializer
@ -33,6 +35,18 @@ class REST::InstanceSerializer < ActiveModel::Serializer
end
end
def icon
SiteUpload::ANDROID_ICON_SIZES.map do |size|
src = app_icon_path(size.to_i)
src = URI.join(root_url, src).to_s if src.present?
{
src: src || frontend_asset_url("icons/android-chrome-#{size}x#{size}.png"),
size: "#{size}x#{size}",
}
end
end
def usage
{
users: {