1
0
Fork 0
forked from gitea/nas

Add emoji_reaction_policy setting

This commit is contained in:
KMY 2023-09-12 16:20:29 +09:00
parent defd790889
commit 673e607e94
15 changed files with 70 additions and 63 deletions

View file

@ -363,28 +363,12 @@ class Account < ApplicationRecord
false
end
def emoji_reactions_must_following?
return false unless Setting.enable_block_emoji_reaction_settings || !local?
return user&.settings&.[]('emoji_reactions.must_be_following') || false if user.present?
return settings['emoji_reactions_must_be_following'] || false if settings.present?
def emoji_reaction_policy
return :allow unless Setting.enable_block_emoji_reaction_settings || !local?
return settings['emoji_reaction_policy']&.to_sym || :allow if settings.present?
return :allow if user.nil?
false
end
def emoji_reactions_must_follower?
return false unless Setting.enable_block_emoji_reaction_settings || !local?
return user&.settings&.[]('emoji_reactions.must_be_follower') || false if user.present?
return settings['emoji_reaction_must_be_follower'] || false if settings.present?
false
end
def emoji_reactions_deny_from_all?
return false unless Setting.enable_block_emoji_reaction_settings || !local?
return user&.settings&.[]('emoji_reactions.deny_from_all') || false if user.present?
return settings['emoji_reaction_deny_from_all'] || false if settings.present?
false
user.settings&.[]('emoji_reaction_policy')&.to_sym
end
def public_settings
@ -400,9 +384,7 @@ class Account < ApplicationRecord
}
if Setting.enable_block_emoji_reaction_settings
config = config.merge({
'emoji_reaction_must_following' => emoji_reactions_must_following?,
'emoji_reaction_must_follower' => emoji_reactions_must_follower?,
'emoji_reaction_deny_from_all' => emoji_reactions_deny_from_all?,
'emoji_reaction_policy' => user&.setting_emoji_reaction_policy,
})
end
config = config.merge(settings) if settings.present?

View file

@ -211,6 +211,10 @@ module AccountInteractions
other_account.following?(self)
end
def mutual?(other_account)
following?(other_account) && followed_by?(other_account)
end
def blocking?(other_account)
block_relationships.where(target_account: other_account).exists?
end

View file

@ -79,6 +79,10 @@ module HasUserSettings
false
end
def setting_emoji_reaction_policy
settings['emoji_reaction_policy']
end
def setting_unfollow_modal
settings['web.unfollow_modal']
end

View file

@ -350,6 +350,8 @@ class Status < ApplicationRecord
end
def emoji_reactions_grouped_by_name(account = nil)
return [] if self.account.emoji_reaction_policy == :block_and_hide
(Oj.load(status_stat&.emoji_reactions || '', mode: :strict) || []).tap do |emoji_reactions|
if account.present?
remove_emoji_reactions = []

View file

@ -36,6 +36,7 @@ class UserSettings
setting :reaction_deck, default: nil
setting :stop_emoji_reaction_streaming, default: false
setting :emoji_reaction_streaming_notify_impl2, default: false
setting :emoji_reaction_policy, default: :allow, in: %w(allow outside_only followers_only followees_only mutuals_only block block_and_hide)
setting :unsafe_limited_distribution, default: false
setting :dtl_force_with_tag, default: :none, in: %w(full searchability none)
setting :dtl_force_subscribable, default: false
@ -84,12 +85,6 @@ class UserSettings
setting :must_be_following_dm, default: false
end
namespace :emoji_reactions do
setting :must_be_follower, default: false
setting :must_be_following, default: false
setting :deny_from_all, default: false
end
def initialize(original_hash)
@original_hash = original_hash || {}
end