From dbc34a82131b76c887ff756ca8db24ff44d7e8e6 Mon Sep 17 00:00:00 2001 From: KMY Date: Wed, 10 May 2023 10:06:55 +0900 Subject: [PATCH] Fix stop emoji reaction streaming to user settings --- .rubocop_todo.yml | 2 ++ app/controllers/settings/profiles_controller.rb | 2 +- app/models/account.rb | 1 - app/models/concerns/has_user_settings.rb | 4 ++++ app/models/user_settings.rb | 1 + .../preferences/notifications/show.html.haml | 4 ++++ app/views/settings/profiles/show.html.haml | 3 --- app/workers/delivery_emoji_reaction_worker.rb | 8 ++++---- config/locales/simple_form.en.yml | 1 + config/locales/simple_form.ja.yml | 2 ++ ...emojis_to_account_statuses_cleanup_policies.rb | 8 ++++++-- ...30423233429_add_dissubscribable_to_accounts.rb | 8 +++++--- ...22606_add_reject_favourite_to_domain_blocks.rb | 8 ++++++-- ...30_add_emoji_reaction_streaming_to_accounts.rb | 2 ++ ...stop_emoji_reaction_streaming_from_accounts.rb | 15 +++++++++++++++ db/schema.rb | 5 ++--- 16 files changed, 55 insertions(+), 19 deletions(-) create mode 100644 db/migrate/20230510004621_remove_stop_emoji_reaction_streaming_from_accounts.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9220549d5d..17ef556999 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -977,6 +977,8 @@ Rails/ThreeStateBooleanColumn: - 'db/migrate/20230314081013_add_group_allow_private_message_to_accounts.rb' - 'db/migrate/20230412005311_add_markdown_to_statuses.rb' - 'db/migrate/20230412073021_add_markdown_to_status_edits.rb' + - 'db/migrate/20230428111230_add_emoji_reaction_streaming_to_accounts.rb' + - 'db/migrate/20230510004621_remove_stop_emoji_reaction_streaming_from_accounts.rb' # Configuration parameters: Include. # Include: app/models/**/*.rb diff --git a/app/controllers/settings/profiles_controller.rb b/app/controllers/settings/profiles_controller.rb index b10b45eb4f..030c3765c2 100644 --- a/app/controllers/settings/profiles_controller.rb +++ b/app/controllers/settings/profiles_controller.rb @@ -20,7 +20,7 @@ class Settings::ProfilesController < Settings::BaseController private def account_params - params.require(:account).permit(:display_name, :note, :avatar, :header, :locked, :my_actor_type, :searchability, :dissubscribable, :stop_emoji_reaction_streaming, :group_allow_private_message, :discoverable, :hide_collections, fields_attributes: [:name, :value]) + params.require(:account).permit(:display_name, :note, :avatar, :header, :locked, :my_actor_type, :searchability, :dissubscribable, :group_allow_private_message, :discoverable, :hide_collections, fields_attributes: [:name, :value]) end def set_account diff --git a/app/models/account.rb b/app/models/account.rb index b35b1e23c9..b6bcd8730c 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -53,7 +53,6 @@ # group_allow_private_message :boolean # searchability :integer default("private"), not null # dissubscribable :boolean default(FALSE), not null -# stop_emoji_reaction_streaming :boolean default(FALSE) # class Account < ApplicationRecord diff --git a/app/models/concerns/has_user_settings.rb b/app/models/concerns/has_user_settings.rb index 94e16f96ca..09c9521c9b 100644 --- a/app/models/concerns/has_user_settings.rb +++ b/app/models/concerns/has_user_settings.rb @@ -43,6 +43,10 @@ module HasUserSettings settings['send_without_domain_blocks'] end + def setting_stop_emoji_reaction_streaming + settings['stop_emoji_reaction_streaming'] + end + def setting_unfollow_modal settings['web.unfollow_modal'] end diff --git a/app/models/user_settings.rb b/app/models/user_settings.rb index de95f325a0..ee519c6117 100644 --- a/app/models/user_settings.rb +++ b/app/models/user_settings.rb @@ -20,6 +20,7 @@ class UserSettings setting :reject_public_unlisted_subscription, default: false setting :reject_unlisted_subscription, default: false setting :send_without_domain_blocks, default: false + setting :stop_emoji_reaction_streaming, default: false namespace :web do setting :crop_images, default: true diff --git a/app/views/settings/preferences/notifications/show.html.haml b/app/views/settings/preferences/notifications/show.html.haml index cb1ad0886d..1f3a0538c3 100644 --- a/app/views/settings/preferences/notifications/show.html.haml +++ b/app/views/settings/preferences/notifications/show.html.haml @@ -33,3 +33,7 @@ = ff.input :'interactions.must_be_follower', wrapper: :with_label, label: I18n.t('simple_form.labels.interactions.must_be_follower') = 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') + + .fields-group + = f.simple_fields_for :settings, current_user.settings do |ff| + = ff.input :stop_emoji_reaction_streaming, as: :boolean, wrapper: :with_label, 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/profiles/show.html.haml b/app/views/settings/profiles/show.html.haml index d6e53b0641..3d7a4325da 100644 --- a/app/views/settings/profiles/show.html.haml +++ b/app/views/settings/profiles/show.html.haml @@ -41,9 +41,6 @@ .fields-group = f.input :dissubscribable, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.dissubscribable') - .fields-group - = f.input :stop_emoji_reaction_streaming, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.stop_emoji_reaction_streaming') - %hr.spacer/ .fields-row diff --git a/app/workers/delivery_emoji_reaction_worker.rb b/app/workers/delivery_emoji_reaction_worker.rb index f156582f1b..b89e17e385 100644 --- a/app/workers/delivery_emoji_reaction_worker.rb +++ b/app/workers/delivery_emoji_reaction_worker.rb @@ -12,12 +12,12 @@ class DeliveryEmojiReactionWorker status = Status.find(status_id.to_i) if status.present? - scope_status(status).where.not(stop_emoji_reaction_streaming: true).find_each do |account| - redis.publish("timeline:#{account.id}", payload_json) if redis.exists?("subscribed:timeline:#{account.id}") + scope_status(status).includes(:user).find_each do |account| + redis.publish("timeline:#{account.id}", payload_json) if !account.user&.setting_stop_emoji_reaction_streaming && redis.exists?("subscribed:timeline:#{account.id}") end - if !([:public, :unlisted, :public_unlisted].include?(status.visibility.to_sym)) && status.account_id != my_account_id && - redis.exists?("subscribed:timeline:#{status.account_id}") + if [:public, :unlisted, :public_unlisted].exclude?(status.visibility.to_sym) && status.account_id != my_account_id && + redis.exists?("subscribed:timeline:#{status.account_id}") redis.publish("timeline:#{status.account_id}", payload_json) end end diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index 552c299d9c..0355784353 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -226,6 +226,7 @@ en: setting_reject_unlisted_subscription: Reject sending unlisted posts to Misskey, Calckey setting_send_without_domain_blocks: Send your post to all server with administrator set as rejecting-post-server for protect you [DEPRECATED] setting_show_application: Disclose application used to send posts + setting_stop_emoji_reaction_streaming: Disable stamp streamings setting_system_font_ui: Use system's default font setting_theme: Site theme setting_trends: Show today's trends diff --git a/config/locales/simple_form.ja.yml b/config/locales/simple_form.ja.yml index ce33febd88..91f037b8d9 100644 --- a/config/locales/simple_form.ja.yml +++ b/config/locales/simple_form.ja.yml @@ -65,6 +65,7 @@ ja: setting_public_post_to_unlisted: 未対応のサードパーティアプリからもローカル公開で投稿できますが、公開投稿はWeb以外できなくなります setting_reject_unlisted_subscription: Misskeyやそのフォーク(Calckeyなど)は、フォローしていないアカウントの「未収載」投稿を **購読・検索** することができます。これはkmyblueの挙動と異なります。そのようなサーバーのうち管理人が指定したものに、指定した公開範囲の投稿を「フォロワーのみ」として配送します。ただし構造上、完璧な対応は困難でたまに未収載として配信されること、ご理解ください setting_show_application: 投稿するのに使用したアプリが投稿の詳細ビューに表示されるようになります + setting_stop_emoji_reaction_streaming: 通信容量の節約に役立ちます setting_use_blurhash: ぼかしはメディアの色を元に生成されますが、細部は見えにくくなっています setting_use_pending_items: 新着があってもタイムラインを自動的にスクロールしないようにします username: アルファベット大文字と小文字、数字、アンダーバー「_」が使えます @@ -230,6 +231,7 @@ ja: setting_reject_unlisted_subscription: 管理者の指定したサーバーに「未収載」投稿を「フォロワーのみ」に変換して配送する setting_send_without_domain_blocks: 管理人の設定した配送停止設定を拒否する (非推奨) setting_show_application: 送信したアプリを開示する + setting_stop_emoji_reaction_streaming: スタンプのストリーミングを停止する setting_system_font_ui: システムのデフォルトフォントを使う setting_theme: サイトテーマ setting_trends: 本日のトレンドタグを表示する diff --git a/db/migrate/20230420081634_add_min_emojis_to_account_statuses_cleanup_policies.rb b/db/migrate/20230420081634_add_min_emojis_to_account_statuses_cleanup_policies.rb index 548b55932d..e381795bf5 100644 --- a/db/migrate/20230420081634_add_min_emojis_to_account_statuses_cleanup_policies.rb +++ b/db/migrate/20230420081634_add_min_emojis_to_account_statuses_cleanup_policies.rb @@ -1,6 +1,10 @@ +# frozen_string_literal: true + class AddMinEmojisToAccountStatusesCleanupPolicies < ActiveRecord::Migration[6.1] def change - add_column :account_statuses_cleanup_policies, :min_emojis, :integer - add_column :account_statuses_cleanup_policies, :keep_self_emoji, :boolean, default: true, null: false + change_table :account_statuses_cleanup_policies, bulk: true do |t| + t.integer :min_emojis + t.boolean :keep_self_emoji, default: true, null: false + end end end diff --git a/db/migrate/20230423233429_add_dissubscribable_to_accounts.rb b/db/migrate/20230423233429_add_dissubscribable_to_accounts.rb index ab05270340..3735e36100 100644 --- a/db/migrate/20230423233429_add_dissubscribable_to_accounts.rb +++ b/db/migrate/20230423233429_add_dissubscribable_to_accounts.rb @@ -2,8 +2,10 @@ class AddDissubscribableToAccounts < ActiveRecord::Migration[6.1] def change - add_column :antennas, :with_media_only, :boolean, null: false, default: false - add_index :antennas, :with_media_only - add_column :accounts, :dissubscribable, :boolean, null: false, default: false + safety_assured do + add_column :antennas, :with_media_only, :boolean, null: false, default: false + add_index :antennas, :with_media_only + add_column :accounts, :dissubscribable, :boolean, null: false, default: false + end end end diff --git a/db/migrate/20230427022606_add_reject_favourite_to_domain_blocks.rb b/db/migrate/20230427022606_add_reject_favourite_to_domain_blocks.rb index f312bdf2d7..b57102ff79 100644 --- a/db/migrate/20230427022606_add_reject_favourite_to_domain_blocks.rb +++ b/db/migrate/20230427022606_add_reject_favourite_to_domain_blocks.rb @@ -1,6 +1,10 @@ +# frozen_string_literal: true + class AddRejectFavouriteToDomainBlocks < ActiveRecord::Migration[6.1] def change - add_column :domain_blocks, :reject_favourite, :boolean, null: false, default: false - add_column :domain_blocks, :reject_reply, :boolean, null: false, default: false + change_table :domain_blocks, bulk: true do |t| + t.boolean :reject_favourite, null: false, default: false + t.boolean :reject_reply, null: false, default: false + end end end diff --git a/db/migrate/20230428111230_add_emoji_reaction_streaming_to_accounts.rb b/db/migrate/20230428111230_add_emoji_reaction_streaming_to_accounts.rb index 222c449bc0..c5f6e3a4b0 100644 --- a/db/migrate/20230428111230_add_emoji_reaction_streaming_to_accounts.rb +++ b/db/migrate/20230428111230_add_emoji_reaction_streaming_to_accounts.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddEmojiReactionStreamingToAccounts < ActiveRecord::Migration[6.1] def change add_column :accounts, :stop_emoji_reaction_streaming, :boolean, default: false diff --git a/db/migrate/20230510004621_remove_stop_emoji_reaction_streaming_from_accounts.rb b/db/migrate/20230510004621_remove_stop_emoji_reaction_streaming_from_accounts.rb new file mode 100644 index 0000000000..3bc96d3893 --- /dev/null +++ b/db/migrate/20230510004621_remove_stop_emoji_reaction_streaming_from_accounts.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class RemoveStopEmojiReactionStreamingFromAccounts < ActiveRecord::Migration[6.1] + def up + safety_assured do + remove_column :accounts, :stop_emoji_reaction_streaming + end + end + + def down + safety_assured do + add_column :accounts, :stop_emoji_reaction_streaming, :boolean, null: true, default: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 3b5b9900b4..5453a4cef9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -12,7 +12,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2023_05_10_000439) do +ActiveRecord::Schema.define(version: 2023_05_10_004621) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -194,7 +194,6 @@ ActiveRecord::Schema.define(version: 2023_05_10_000439) do t.boolean "group_allow_private_message" t.integer "searchability", default: 2, null: false t.boolean "dissubscribable", default: false, null: false - t.boolean "stop_emoji_reaction_streaming", default: false t.index "(((setweight(to_tsvector('simple'::regconfig, (display_name)::text), 'A'::\"char\") || setweight(to_tsvector('simple'::regconfig, (username)::text), 'B'::\"char\")) || setweight(to_tsvector('simple'::regconfig, (COALESCE(domain, ''::character varying))::text), 'C'::\"char\")))", name: "search_index", using: :gin t.index "lower((username)::text), COALESCE(lower((domain)::text), ''::text)", name: "index_accounts_on_username_and_domain_lower", unique: true t.index ["moved_to_account_id"], name: "index_accounts_on_moved_to_account_id", where: "(moved_to_account_id IS NOT NULL)" @@ -1484,4 +1483,4 @@ ActiveRecord::Schema.define(version: 2023_05_10_000439) do end -# rubocop:enable all +#rubocop:enable all