Class: NewsmastMastodon::Api::V1::LocalOnlyPostsController

Inherits:
Api::BaseController
  • Object
show all
Includes:
Authorization
Defined in:
app/controllers/newsmast_mastodon/api/v1/local_only_posts_controller.rb

Instance Method Summary collapse

Instance Method Details

#getLocalOnlySettingObject



6
7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/newsmast_mastodon/api/v1/local_only_posts_controller.rb', line 6

def getLocalOnlySetting
  # Early return if NewsmastMastodon::ServerSetting doesn't exist
  unless Object.const_defined?('NewsmastMastodon::ServerSetting')
    return render json: { local_only: false }, status: :ok
  end

  setting = NewsmastMastodon::ServerSetting.find_by(name: "Local only posts")
  return render json: { local_only: false }, status: :ok if setting.nil?

  render json: { local_only: setting.value }, status: :ok
end