From 35c2bb9f44995cda6f847071a2087bfd5e1628a4 Mon Sep 17 00:00:00 2001 From: KMY Date: Wed, 13 Sep 2023 13:17:54 +0900 Subject: [PATCH] Remove emoji reaction from fedibird_capabilities and setting pages when disabled --- .../v1/statuses/emoji_reactions_controller.rb | 1 + app/serializers/rest/instance_serializer.rb | 18 ++---------------- app/serializers/rest/v1/instance_serializer.rb | 18 ++---------------- .../preferences/appearance/show.html.haml | 5 +++-- .../preferences/notifications/show.html.haml | 7 ++++--- .../settings/preferences/other/show.html.haml | 7 ++++--- app/workers/delivery_emoji_reaction_worker.rb | 2 ++ config/locales/en.yml | 1 + config/locales/ja.yml | 1 + 9 files changed, 20 insertions(+), 40 deletions(-) diff --git a/app/controllers/api/v1/statuses/emoji_reactions_controller.rb b/app/controllers/api/v1/statuses/emoji_reactions_controller.rb index a86f1d394b..4dc4bd92c8 100644 --- a/app/controllers/api/v1/statuses/emoji_reactions_controller.rb +++ b/app/controllers/api/v1/statuses/emoji_reactions_controller.rb @@ -42,6 +42,7 @@ class Api::V1::Statuses::EmojiReactionsController < Api::BaseController def create_private(emoji) count = EmojiReaction.where(account: current_account, status: @status).count raise Mastodon::ValidationError, I18n.t('reactions.errors.limit_reached') if count >= EmojiReaction::EMOJI_REACTION_PER_ACCOUNT_LIMIT + raise Mastodon::ValidationError, I18n.t('reactions.errors.disabled') unless Setting.enable_emoji_reaction EmojiReactService.new.call(current_account, @status, emoji) render json: @status, serializer: REST::StatusSerializer diff --git a/app/serializers/rest/instance_serializer.rb b/app/serializers/rest/instance_serializer.rb index fd8c28e0df..c8b4740bff 100644 --- a/app/serializers/rest/instance_serializer.rb +++ b/app/serializers/rest/instance_serializer.rb @@ -11,7 +11,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer attributes :domain, :title, :version, :source_url, :description, :usage, :thumbnail, :languages, :configuration, - :registrations, :fedibird_capabilities, :kmyblue_capabilities + :registrations, :fedibird_capabilities has_one :contact, serializer: ContactSerializer has_many :rules, serializer: REST::RuleSerializer @@ -108,7 +108,6 @@ class REST::InstanceSerializer < ActiveModel::Serializer # for third party apps def fedibird_capabilities capabilities = [ - :emoji_reaction, :kmyblue_visibility_public_unlisted, :enable_wide_emoji, :enable_wide_emoji_reaction, @@ -126,24 +125,11 @@ class REST::InstanceSerializer < ActiveModel::Serializer ] capabilities << :profile_search unless Chewy.enabled? + capabilities << :emoji_reaction if Setting.enable_emoji_reaction capabilities end - def kmyblue_capabilities - %i( - visibility_public_unlisted - searchability - markdown - reaction_deck - visibility_login - limited_scope - antenna - bookmark_category - status_expiration - ) - end - private def registrations_enabled? diff --git a/app/serializers/rest/v1/instance_serializer.rb b/app/serializers/rest/v1/instance_serializer.rb index cbbc0ac8ec..9e801a7898 100644 --- a/app/serializers/rest/v1/instance_serializer.rb +++ b/app/serializers/rest/v1/instance_serializer.rb @@ -6,7 +6,7 @@ class REST::V1::InstanceSerializer < ActiveModel::Serializer attributes :uri, :title, :short_description, :description, :email, :version, :urls, :stats, :thumbnail, :languages, :registrations, :approval_required, :invites_enabled, - :configuration, :fedibird_capabilities, :kmyblue_capabilities + :configuration, :fedibird_capabilities has_one :contact_account, serializer: REST::AccountSerializer @@ -117,7 +117,6 @@ class REST::V1::InstanceSerializer < ActiveModel::Serializer # for third party apps def fedibird_capabilities capabilities = [ - :emoji_reaction, :kmyblue_visibility_public_unlisted, :enable_wide_emoji, :enable_wide_emoji_reaction, @@ -135,24 +134,11 @@ class REST::V1::InstanceSerializer < ActiveModel::Serializer ] capabilities << :profile_search unless Chewy.enabled? + capabilities << :emoji_reaction if Setting.enable_emoji_reaction capabilities end - def kmyblue_capabilities - %i( - visibility_public_unlisted - searchability - markdown - reaction_deck - visibility_login - limited_scope - antenna - bookmark_category - status_expiration - ) - end - private def instance_presenter diff --git a/app/views/settings/preferences/appearance/show.html.haml b/app/views/settings/preferences/appearance/show.html.haml index 95ba554c71..aaa24794fb 100644 --- a/app/views/settings/preferences/appearance/show.html.haml +++ b/app/views/settings/preferences/appearance/show.html.haml @@ -39,8 +39,9 @@ .fields-group = ff.input :'web.hide_recent_emojis', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_hide_recent_emojis'), hint: false - = ff.input :'web.enable_emoji_reaction', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_enable_emoji_reaction'), hint: I18n.t('simple_form.hints.defaults.setting_enable_emoji_reaction') - = ff.input :'web.show_emoji_reaction_on_timeline', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_show_emoji_reaction_on_timeline') + - if Setting.enable_emoji_reaction + = ff.input :'web.enable_emoji_reaction', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_enable_emoji_reaction'), hint: I18n.t('simple_form.hints.defaults.setting_enable_emoji_reaction') + = ff.input :'web.show_emoji_reaction_on_timeline', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_show_emoji_reaction_on_timeline') .fields-group = ff.input :'web.bookmark_category_needed', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_bookmark_category_needed'), hint: I18n.t('simple_form.hints.defaults.setting_bookmark_category_needed') diff --git a/app/views/settings/preferences/notifications/show.html.haml b/app/views/settings/preferences/notifications/show.html.haml index 924a351b1a..06af9c1360 100644 --- a/app/views/settings/preferences/notifications/show.html.haml +++ b/app/views/settings/preferences/notifications/show.html.haml @@ -43,6 +43,7 @@ = ff.input :'interactions.must_be_following', wrapper: :with_label, label: I18n.t('simple_form.labels.interactions.must_be_following') = ff.input :'interactions.must_be_following_dm', wrapper: :with_label, label: I18n.t('simple_form.labels.interactions.must_be_following_dm') - = f.simple_fields_for :settings, current_user.settings do |ff| - .fields-group - = ff.input :stop_emoji_reaction_streaming, as: :boolean, wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_stop_emoji_reaction_streaming'), hint: I18n.t('simple_form.hints.defaults.setting_stop_emoji_reaction_streaming') + - if Setting.enable_emoji_reaction + = f.simple_fields_for :settings, current_user.settings do |ff| + .fields-group + = ff.input :stop_emoji_reaction_streaming, as: :boolean, wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_stop_emoji_reaction_streaming'), hint: I18n.t('simple_form.hints.defaults.setting_stop_emoji_reaction_streaming') diff --git a/app/views/settings/preferences/other/show.html.haml b/app/views/settings/preferences/other/show.html.haml index 76e2db68d2..641efde9df 100644 --- a/app/views/settings/preferences/other/show.html.haml +++ b/app/views/settings/preferences/other/show.html.haml @@ -20,9 +20,10 @@ .fields-group = ff.input :default_sensitive, wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_default_sensitive'), hint: I18n.t('simple_form.hints.defaults.setting_default_sensitive') - .fields-row - .fields-group.fields-row__column.fields-row__column-12 - = ff.input :emoji_reaction_policy, kmyblue: true, collection: ['allow', 'outside_only', 'followers_only', 'following_only', 'mutuals_only', 'block'], label_method: lambda { |item| safe_join([t("simple_form.labels.defaults.setting_emoji_reaction_policy_items.#{item}")]) }, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li', include_blank: false, wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_emoji_reaction_policy'), hint: false, warning_hint: I18n.t('simple_form.hints.defaults.setting_emoji_reaction_policy') + - if Setting.enable_emoji_reaction + .fields-row + .fields-group.fields-row__column.fields-row__column-12 + = ff.input :emoji_reaction_policy, kmyblue: true, collection: ['allow', 'outside_only', 'followers_only', 'following_only', 'mutuals_only', 'block'], label_method: lambda { |item| safe_join([t("simple_form.labels.defaults.setting_emoji_reaction_policy_items.#{item}")]) }, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li', include_blank: false, wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_emoji_reaction_policy'), hint: false, warning_hint: I18n.t('simple_form.hints.defaults.setting_emoji_reaction_policy') - if @dtl_enabled diff --git a/app/workers/delivery_emoji_reaction_worker.rb b/app/workers/delivery_emoji_reaction_worker.rb index cb80c878e3..e38b61d9ac 100644 --- a/app/workers/delivery_emoji_reaction_worker.rb +++ b/app/workers/delivery_emoji_reaction_worker.rb @@ -7,6 +7,8 @@ class DeliveryEmojiReactionWorker include AccountScope def perform(payload_json, status_id, reacted_account_id) + return unless Setting.enable_emoji_reaction + status = Status.find(status_id) reacted_account = Account.find(reacted_account_id) diff --git a/config/locales/en.yml b/config/locales/en.yml index b84ee25ba1..37fb3cdc04 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1674,6 +1674,7 @@ en: reactions: errors: banned: Banned reaction from the user + disabled: Stamp is disabled on this server duplication: Cannot react same things limit_reached: Limit of different reactions reached unrecognized_emoji: is not a recognized emoji diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 2e344602ab..352ed2f07e 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -1613,6 +1613,7 @@ ja: reactions: errors: banned: 指定ユーザーからのリアクションは禁止されています + disabled: このサーバーではスタンプ機能は無効になっています duplication: 同じリアクションを複数行おうとしました limit_reached: リアクションの種類が上限に達しました unrecognized_emoji: は絵文字として認識されていません