Add server banner to web app, add GET /api/v2/instance to REST API (#19294)
				
					
				
			This commit is contained in:
		@@ -1,19 +1,51 @@
 | 
			
		||||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
class InstancePresenter
 | 
			
		||||
  delegate(
 | 
			
		||||
    :site_contact_email,
 | 
			
		||||
    :site_title,
 | 
			
		||||
    :site_short_description,
 | 
			
		||||
    :site_description,
 | 
			
		||||
    :site_extended_description,
 | 
			
		||||
    :site_terms,
 | 
			
		||||
    :closed_registrations_message,
 | 
			
		||||
    to: Setting
 | 
			
		||||
  )
 | 
			
		||||
class InstancePresenter < ActiveModelSerializers::Model
 | 
			
		||||
  attributes :domain, :title, :version, :source_url,
 | 
			
		||||
             :description, :languages, :rules, :contact
 | 
			
		||||
 | 
			
		||||
  def contact_account
 | 
			
		||||
    Account.find_local(Setting.site_contact_username.strip.gsub(/\A@/, ''))
 | 
			
		||||
  class ContactPresenter < ActiveModelSerializers::Model
 | 
			
		||||
    attributes :email, :account
 | 
			
		||||
 | 
			
		||||
    def email
 | 
			
		||||
      Setting.site_contact_email
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def account
 | 
			
		||||
      Account.find_local(Setting.site_contact_username.strip.gsub(/\A@/, ''))
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def contact
 | 
			
		||||
    ContactPresenter.new
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def closed_registrations_message
 | 
			
		||||
    Setting.closed_registrations_message
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def description
 | 
			
		||||
    Setting.site_short_description
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def extended_description
 | 
			
		||||
    Setting.site_extended_description
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def privacy_policy
 | 
			
		||||
    Setting.site_terms
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def domain
 | 
			
		||||
    Rails.configuration.x.local_domain
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def title
 | 
			
		||||
    Setting.site_title
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def languages
 | 
			
		||||
    [I18n.default_locale]
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def rules
 | 
			
		||||
@@ -40,8 +72,8 @@ class InstancePresenter
 | 
			
		||||
    Rails.cache.fetch('sample_accounts', expires_in: 12.hours) { Account.local.discoverable.popular.limit(3) }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def version_number
 | 
			
		||||
    Mastodon::Version
 | 
			
		||||
  def version
 | 
			
		||||
    Mastodon::Version.to_s
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def source_url
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user