diff --git a/app/controllers/api/base_controller.rb b/app/controllers/api/base_controller.rb index e6240d6f3..083f15108 100644 --- a/app/controllers/api/base_controller.rb +++ b/app/controllers/api/base_controller.rb @@ -132,4 +132,17 @@ class Api::BaseController < ApplicationController def disallow_unauthenticated_api_access? authorized_fetch_mode? end + + def application + doorkeeper_token&.application + end + + def mastodon_for_ios? + application&.name == 'Mastodon for iOS' + end + + def mastodon_for_android? + application&.name == 'Mastodon for Android' + end + end diff --git a/app/controllers/api/v1/accounts/credentials_controller.rb b/app/controllers/api/v1/accounts/credentials_controller.rb index 787442aae..2aaab6056 100644 --- a/app/controllers/api/v1/accounts/credentials_controller.rb +++ b/app/controllers/api/v1/accounts/credentials_controller.rb @@ -6,7 +6,10 @@ class Api::V1::Accounts::CredentialsController < Api::BaseController before_action :require_user! def show - @account = current_account + @account = current_account.tap do |account| + account.locked = false if account.user.setting_unlocked_for_official_app && (mastodon_for_ios? || mastodon_for_android?) + end + render json: @account, serializer: REST::CredentialAccountSerializer end diff --git a/app/controllers/api/v1/accounts_controller.rb b/app/controllers/api/v1/accounts_controller.rb index 0a6846fa1..3cdd23847 100644 --- a/app/controllers/api/v1/accounts_controller.rb +++ b/app/controllers/api/v1/accounts_controller.rb @@ -94,7 +94,9 @@ class Api::V1::AccountsController < Api::BaseController private def set_account - @account = Account.find(params[:id]) + @account = Account.find(params[:id]).tap do |account| + account.locked = false if account == current_account && current_user.setting_unlocked_for_official_app && (mastodon_for_ios? || mastodon_for_android?) + end end def relationships(**options) diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb index 8ee754362..831b5adf8 100644 --- a/app/controllers/settings/preferences_controller.rb +++ b/app/controllers/settings/preferences_controller.rb @@ -125,6 +125,7 @@ class Settings::PreferencesController < Settings::BaseController :setting_hide_link_preview, :setting_hide_photo_preview, :setting_hide_video_preview, + :setting_unlocked_for_official_app, setting_prohibited_visibilities: [], notification_emails: %i(follow follow_request reblog favourite emoji_reaction status_reference mention digest report pending_account trending_tag), interactions: %i(must_be_follower must_be_following must_be_following_dm must_be_dm_to_send_email must_be_following_reference) diff --git a/app/lib/user_settings_decorator.rb b/app/lib/user_settings_decorator.rb index 15a5da488..af9666eb8 100644 --- a/app/lib/user_settings_decorator.rb +++ b/app/lib/user_settings_decorator.rb @@ -102,6 +102,7 @@ class UserSettingsDecorator hide_video_preview enable_wide_emoji enable_wide_emoji_reaction + unlocked_for_official_app ).freeze STRING_KEYS = %w( diff --git a/app/models/user.rb b/app/models/user.rb index 7be7c11ed..99468a2bc 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -148,6 +148,7 @@ class User < ApplicationRecord :prohibited_visibilities, :prohibited_words, :disable_relative_time, :hide_direct_from_timeline, :hide_personal_from_timeline, :hide_personal_from_account, :hide_privacy_meta, :hide_link_preview, :hide_photo_preview, :hide_video_preview, + :unlocked_for_official_app, to: :settings, prefix: :setting, allow_nil: false diff --git a/app/views/settings/preferences/other/show.html.haml b/app/views/settings/preferences/other/show.html.haml index cef181ade..9174c241f 100644 --- a/app/views/settings/preferences/other/show.html.haml +++ b/app/views/settings/preferences/other/show.html.haml @@ -137,6 +137,9 @@ .fields-group = f.input :setting_hide_privacy_meta, as: :boolean, wrapper: :with_label, fedibird_features: true + .fields-group + = f.input :setting_unlocked_for_official_app, as: :boolean, wrapper: :with_label, fedibird_features: true + %h4= t 'preferences.public_timelines' .fields-group diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index f42e2bd3d..5e0713457 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -135,6 +135,7 @@ en: setting_theme_instance_ticker_type-2: Type-2 (Favicon + BG White) setting_theme_instance_ticker_type-3: Type-3 (Favicon + BG Black) setting_theme_public: Your public pages will reflect the theme currently in use + setting_unlocked_for_official_app: Force the official Mastodon app to recognize the account follow approval-only as disabled, making the default visibility public setting_use_blurhash: Gradients are based on the colors of the hidden visuals but obfuscate any details setting_use_pending_items: Hide timeline updates behind a click instead of automatically scrolling the feed username: Your username will be unique on %{domain} @@ -344,6 +345,7 @@ en: setting_theme_public: Reflecting the theme on the public page setting_trends: Show today's trends setting_unfollow_modal: Show confirmation dialog before unfollowing someone + setting_unlocked_for_official_app: Disable follow approval-only for against the official Mastodon App setting_unsubscribe_modal: Show confirmation dialog before unsubscribing someone setting_use_blurhash: Show colorful gradients for hidden media setting_use_pending_items: Slow mode diff --git a/config/locales/simple_form.ja.yml b/config/locales/simple_form.ja.yml index 9681b33de..eac486e19 100644 --- a/config/locales/simple_form.ja.yml +++ b/config/locales/simple_form.ja.yml @@ -131,6 +131,7 @@ ja: setting_theme_instance_ticker_type-2: Type-2 (Favicon + 白背景) setting_theme_instance_ticker_type-3: Type-3 (Favicon + 黒背景) setting_theme_public: あなたの公開ページに現在使用中のテーマを反映します + setting_unlocked_for_official_app: Mastodon公式アプリに対し、アカウントのフォロー承認制を強制的に無効と認識させることで、デフォルトの可視性を公開にします。 setting_use_blurhash: ぼかしはメディアの色を元に生成されますが、細部は見えにくくなっています setting_use_pending_items: 新着があってもタイムラインを自動的にスクロールしないようにします username: あなたのユーザー名は %{domain} の中で重複していない必要があります @@ -340,6 +341,7 @@ ja: setting_theme_public: 公開ページにテーマを反映する setting_trends: 本日のトレンドタグを表示する setting_unfollow_modal: フォローを解除する前に確認ダイアログを表示する + setting_unlocked_for_official_app: Mastodon公式アプリに対し、フォロー承認制を無効にする setting_unsubscribe_modal: 購読を解除する前に確認ダイアログを表示する setting_use_blurhash: 非表示のメディアを色付きのぼかしで表示する setting_use_pending_items: 手動更新モード diff --git a/config/settings.yml b/config/settings.yml index f94fd0cb9..b75e5f34d 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -75,6 +75,7 @@ defaults: &defaults picker_emoji_size: 22, enable_wide_emoji: true enable_wide_emoji_reaction: true + unlocked_for_official_app: false notification_emails: follow: false reblog: false