Connect emoji_reaction block settings and show settings
This commit is contained in:
parent
4863ac50a0
commit
58137b227c
5 changed files with 36 additions and 32 deletions
|
@ -370,6 +370,34 @@ class Account < ApplicationRecord
|
||||||
user.settings&.[]('emoji_reaction_policy')&.to_sym
|
user.settings&.[]('emoji_reaction_policy')&.to_sym
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def show_emoji_reaction?(account)
|
||||||
|
case emoji_reaction_policy
|
||||||
|
when :block_and_hide
|
||||||
|
false
|
||||||
|
when :followees_only
|
||||||
|
account.present? && (id == account.id || following?(account))
|
||||||
|
when :followers_only
|
||||||
|
account.present? && (id == account.id || followed_by?(account))
|
||||||
|
when :mutuals_only
|
||||||
|
account.present? && (id == account.id || mutual?(account))
|
||||||
|
when :outside_only
|
||||||
|
account.present? && (id == account.id || following?(account) || followed_by?(account))
|
||||||
|
else
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def allow_emoji_reaction?(account)
|
||||||
|
return false if account.nil?
|
||||||
|
|
||||||
|
case emoji_reaction_policy
|
||||||
|
when :block
|
||||||
|
false
|
||||||
|
else
|
||||||
|
show_emoji_reaction?(account)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def public_settings
|
def public_settings
|
||||||
config = {
|
config = {
|
||||||
'noindex' => noindex?,
|
'noindex' => noindex?,
|
||||||
|
|
|
@ -350,7 +350,7 @@ class Status < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def emoji_reactions_grouped_by_name(account = nil)
|
def emoji_reactions_grouped_by_name(account = nil)
|
||||||
return [] if self.account.emoji_reaction_policy == :block_and_hide
|
return [] if account.present? && !self.account.show_emoji_reaction?(account)
|
||||||
|
|
||||||
(Oj.load(status_stat&.emoji_reactions || '', mode: :strict) || []).tap do |emoji_reactions|
|
(Oj.load(status_stat&.emoji_reactions || '', mode: :strict) || []).tap do |emoji_reactions|
|
||||||
if account.present?
|
if account.present?
|
||||||
|
|
|
@ -22,30 +22,6 @@ class EmojiReactionValidator < ActiveModel::Validator
|
||||||
end
|
end
|
||||||
|
|
||||||
def deny_emoji_reactions?(emoji_reaction)
|
def deny_emoji_reactions?(emoji_reaction)
|
||||||
return false if emoji_reaction.status.account.user.nil?
|
!emoji_reaction.status.account.allow_emoji_reaction?(emoji_reaction.account)
|
||||||
return deny_from_all?(emoji_reaction) if emoji_reaction.status.account_id == emoji_reaction.account_id
|
|
||||||
return false if emoji_reaction.status.account.emoji_reaction_policy == :allow
|
|
||||||
|
|
||||||
deny_from_all?(emoji_reaction) || non_outside?(emoji_reaction) || non_follower?(emoji_reaction) || non_following?(emoji_reaction) || non_mutual?(emoji_reaction)
|
|
||||||
end
|
|
||||||
|
|
||||||
def deny_from_all?(emoji_reaction)
|
|
||||||
%i(block block_and_hide).include?(emoji_reaction.status.account.emoji_reaction_policy)
|
|
||||||
end
|
|
||||||
|
|
||||||
def non_following?(emoji_reaction)
|
|
||||||
emoji_reaction.status.account.emoji_reaction_policy == :followees_only && !emoji_reaction.status.account.following?(emoji_reaction.account)
|
|
||||||
end
|
|
||||||
|
|
||||||
def non_follower?(emoji_reaction)
|
|
||||||
emoji_reaction.status.account.emoji_reaction_policy == :followers_only && !emoji_reaction.account.following?(emoji_reaction.status.account)
|
|
||||||
end
|
|
||||||
|
|
||||||
def non_outside?(emoji_reaction)
|
|
||||||
emoji_reaction.status.account.emoji_reaction_policy == :outside_only && !emoji_reaction.account.following?(emoji_reaction.status.account) && !emoji_reaction.status.account.following?(emoji_reaction.account)
|
|
||||||
end
|
|
||||||
|
|
||||||
def non_mutual?(emoji_reaction)
|
|
||||||
emoji_reaction.status.account.emoji_reaction_policy == :mutuals_only && !emoji_reaction.status.account.mutual?(emoji_reaction.account)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -244,11 +244,11 @@ en:
|
||||||
setting_emoji_reaction_streaming_notify_impl2: Enable stamp notification compat with Nyastodon, Catstodon, glitch-soc
|
setting_emoji_reaction_streaming_notify_impl2: Enable stamp notification compat with Nyastodon, Catstodon, glitch-soc
|
||||||
setting_enable_emoji_reaction: Show emoji reaction on your display
|
setting_enable_emoji_reaction: Show emoji reaction on your display
|
||||||
setting_enable_login_privacy: Enable login visibility
|
setting_enable_login_privacy: Enable login visibility
|
||||||
setting_emoji_reaction_policy: Stamp policy
|
setting_emoji_reaction_policy: Stamp receive/display policy
|
||||||
setting_emoji_reaction_policy_items:
|
setting_emoji_reaction_policy_items:
|
||||||
allow: Allow all
|
allow: Allow all
|
||||||
block: Block all
|
block: Block all but show existing reactions
|
||||||
block_and_hide: Block and hide
|
block_and_hide: Block
|
||||||
followees_only: Followings only
|
followees_only: Followings only
|
||||||
followers_only: Followers only
|
followers_only: Followers only
|
||||||
mutuals_only: Mutuals only
|
mutuals_only: Mutuals only
|
||||||
|
|
|
@ -252,11 +252,11 @@ ja:
|
||||||
setting_dtl_force_with_tag: DTL参加時の投稿設定
|
setting_dtl_force_with_tag: DTL参加時の投稿設定
|
||||||
setting_dtl_menu: Webクライアントのメニューにディープタイムラインを追加する
|
setting_dtl_menu: Webクライアントのメニューにディープタイムラインを追加する
|
||||||
setting_enable_login_privacy: 公開範囲「ログインユーザーのみ」をWeb UIで選択可能にする
|
setting_enable_login_privacy: 公開範囲「ログインユーザーのみ」をWeb UIで選択可能にする
|
||||||
setting_emoji_reaction_policy: スタンプ受け入れ設定
|
setting_emoji_reaction_policy: スタンプ受け入れと表示設定
|
||||||
setting_emoji_reaction_policy_items:
|
setting_emoji_reaction_policy_items:
|
||||||
allow: 全員に許可
|
allow: 全員に許可
|
||||||
block: 全員禁止
|
block: 全員禁止するが、既存のスタンプは表示する
|
||||||
block_and_hide: 全員禁止し、既存のスタンプも非表示にする
|
block_and_hide: 全員禁止
|
||||||
followees_only: フォロー中の相手のみ許可
|
followees_only: フォロー中の相手のみ許可
|
||||||
followers_only: フォロワーのみ許可
|
followers_only: フォロワーのみ許可
|
||||||
mutuals_only: 相互のみ許可
|
mutuals_only: 相互のみ許可
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue