Add enable_block_emoji_reaction_settings setting
This commit is contained in:
parent
a1cfab66cf
commit
bf0d6fd2f5
7 changed files with 21 additions and 11 deletions
|
@ -336,6 +336,7 @@ class Account < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def emoji_reactions_must_following?
|
def emoji_reactions_must_following?
|
||||||
|
return false unless Setting.enable_block_emoji_reaction_settings
|
||||||
return user&.settings&.[]('emoji_reactions.must_be_following') || false if user.present?
|
return user&.settings&.[]('emoji_reactions.must_be_following') || false if user.present?
|
||||||
return settings['emoji_reactions_must_be_following'] || false if settings.present?
|
return settings['emoji_reactions_must_be_following'] || false if settings.present?
|
||||||
|
|
||||||
|
@ -343,6 +344,7 @@ class Account < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def emoji_reactions_must_follower?
|
def emoji_reactions_must_follower?
|
||||||
|
return false unless Setting.enable_block_emoji_reaction_settings
|
||||||
return user&.settings&.[]('emoji_reactions.must_be_follower') || false if user.present?
|
return user&.settings&.[]('emoji_reactions.must_be_follower') || false if user.present?
|
||||||
return settings['emoji_reaction_must_be_follower'] || false if settings.present?
|
return settings['emoji_reaction_must_be_follower'] || false if settings.present?
|
||||||
|
|
||||||
|
@ -350,6 +352,7 @@ class Account < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def emoji_reactions_deny_from_all?
|
def emoji_reactions_deny_from_all?
|
||||||
|
return false unless Setting.enable_block_emoji_reaction_settings
|
||||||
return user&.settings&.[]('emoji_reactions.deny_from_all') || false if user.present?
|
return user&.settings&.[]('emoji_reactions.deny_from_all') || false if user.present?
|
||||||
return settings['emoji_reaction_deny_from_all'] || false if settings.present?
|
return settings['emoji_reaction_deny_from_all'] || false if settings.present?
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ class Form::AdminSettings
|
||||||
status_page_url
|
status_page_url
|
||||||
captcha_enabled
|
captcha_enabled
|
||||||
ng_words
|
ng_words
|
||||||
|
enable_block_emoji_reaction_settings
|
||||||
).freeze
|
).freeze
|
||||||
|
|
||||||
INTEGER_KEYS = %i(
|
INTEGER_KEYS = %i(
|
||||||
|
@ -55,6 +56,7 @@ class Form::AdminSettings
|
||||||
noindex
|
noindex
|
||||||
require_invite_text
|
require_invite_text
|
||||||
captcha_enabled
|
captcha_enabled
|
||||||
|
enable_block_emoji_reaction_settings
|
||||||
).freeze
|
).freeze
|
||||||
|
|
||||||
UPLOAD_KEYS = %i(
|
UPLOAD_KEYS = %i(
|
||||||
|
|
|
@ -8,7 +8,7 @@ class EmojiReactionValidator < ActiveModel::Validator
|
||||||
|
|
||||||
emoji_reaction.errors.add(:name, I18n.t('reactions.errors.unrecognized_emoji')) if emoji_reaction.custom_emoji_id.blank? && !unicode_emoji?(emoji_reaction.name)
|
emoji_reaction.errors.add(:name, I18n.t('reactions.errors.unrecognized_emoji')) if emoji_reaction.custom_emoji_id.blank? && !unicode_emoji?(emoji_reaction.name)
|
||||||
emoji_reaction.errors.add(:name, I18n.t('reactions.errors.unrecognized_emoji')) if emoji_reaction.custom_emoji_id.present? && disabled_custom_emoji?(emoji_reaction.custom_emoji)
|
emoji_reaction.errors.add(:name, I18n.t('reactions.errors.unrecognized_emoji')) if emoji_reaction.custom_emoji_id.present? && disabled_custom_emoji?(emoji_reaction.custom_emoji)
|
||||||
emoji_reaction.errors.add(:name, I18n.t('reactions.errors.banned')) if deny_from_all?(emoji_reaction) || non_follower?(emoji_reaction) || non_following?(emoji_reaction)
|
emoji_reaction.errors.add(:name, I18n.t('reactions.errors.banned')) if deny_emoji_reactions?(emoji_reaction)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -21,24 +21,23 @@ class EmojiReactionValidator < ActiveModel::Validator
|
||||||
custom_emoji.nil? ? false : custom_emoji.disabled
|
custom_emoji.nil? ? false : custom_emoji.disabled
|
||||||
end
|
end
|
||||||
|
|
||||||
def deny_from_all?(emoji_reaction)
|
def deny_emoji_reactions?(emoji_reaction)
|
||||||
|
return false unless Setting.enable_block_emoji_reaction_settings
|
||||||
return false if emoji_reaction.status.account.user.nil?
|
return false if emoji_reaction.status.account.user.nil?
|
||||||
return false if emoji_reaction.status.account_id == emoji_reaction.account_id
|
return false if emoji_reaction.status.account_id == emoji_reaction.account_id
|
||||||
|
|
||||||
|
deny_from_all?(emoji_reaction) || non_follower?(emoji_reaction) || non_following?(emoji_reaction)
|
||||||
|
end
|
||||||
|
|
||||||
|
def deny_from_all?(emoji_reaction)
|
||||||
emoji_reaction.status.account.user.settings['emoji_reactions.deny_from_all']
|
emoji_reaction.status.account.user.settings['emoji_reactions.deny_from_all']
|
||||||
end
|
end
|
||||||
|
|
||||||
def non_following?(emoji_reaction)
|
def non_following?(emoji_reaction)
|
||||||
return false if emoji_reaction.status.account.user.nil?
|
|
||||||
return false if emoji_reaction.status.account_id == emoji_reaction.account_id
|
|
||||||
|
|
||||||
emoji_reaction.status.account.user.settings['emoji_reactions.must_be_following'] && !emoji_reaction.status.account.following?(emoji_reaction.account)
|
emoji_reaction.status.account.user.settings['emoji_reactions.must_be_following'] && !emoji_reaction.status.account.following?(emoji_reaction.account)
|
||||||
end
|
end
|
||||||
|
|
||||||
def non_follower?(emoji_reaction)
|
def non_follower?(emoji_reaction)
|
||||||
return false if emoji_reaction.status.account.user.nil?
|
|
||||||
return false if emoji_reaction.status.account_id == emoji_reaction.account_id
|
|
||||||
|
|
||||||
emoji_reaction.status.account.user.settings['emoji_reactions.must_be_follower'] && !emoji_reaction.account.following?(emoji_reaction.status.account)
|
emoji_reaction.status.account.user.settings['emoji_reactions.must_be_follower'] && !emoji_reaction.account.following?(emoji_reaction.status.account)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,5 +10,8 @@
|
||||||
.fields-group
|
.fields-group
|
||||||
= f.input :ng_words, wrapper: :with_label, as: :text, input_html: { rows: 12 }, label: t('admin.ng_words.keywords')
|
= f.input :ng_words, wrapper: :with_label, as: :text, input_html: { rows: 12 }, label: t('admin.ng_words.keywords')
|
||||||
|
|
||||||
|
.fields-group
|
||||||
|
= f.input :enable_block_emoji_reaction_settings, wrapper: :with_label, as: :boolean, label: t('admin.ng_words.enable_block_emoji_reaction_settings')
|
||||||
|
|
||||||
.actions
|
.actions
|
||||||
= f.button :button, t('generic.save_changes'), type: :submit
|
= f.button :button, t('generic.save_changes'), type: :submit
|
||||||
|
|
|
@ -33,9 +33,10 @@
|
||||||
= ff.input :'interactions.must_be_follower', wrapper: :with_label, label: I18n.t('simple_form.labels.interactions.must_be_follower')
|
= 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', 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')
|
= ff.input :'interactions.must_be_following_dm', wrapper: :with_label, label: I18n.t('simple_form.labels.interactions.must_be_following_dm')
|
||||||
= ff.input :'emoji_reactions.must_be_follower', kmyblue: true, wrapper: :with_label, label: I18n.t('simple_form.labels.emoji_reactions.must_be_follower')
|
- if Setting.enable_block_emoji_reaction_settings
|
||||||
= ff.input :'emoji_reactions.must_be_following', kmyblue: true, wrapper: :with_label, label: I18n.t('simple_form.labels.emoji_reactions.must_be_following')
|
= ff.input :'emoji_reactions.must_be_follower', kmyblue: true, wrapper: :with_label, label: I18n.t('simple_form.labels.emoji_reactions.must_be_follower')
|
||||||
= ff.input :'emoji_reactions.deny_from_all', kmyblue: true, wrapper: :with_label, label: I18n.t('simple_form.labels.emoji_reactions.deny_from_all')
|
= ff.input :'emoji_reactions.must_be_following', kmyblue: true, wrapper: :with_label, label: I18n.t('simple_form.labels.emoji_reactions.must_be_following')
|
||||||
|
= ff.input :'emoji_reactions.deny_from_all', kmyblue: true, wrapper: :with_label, label: I18n.t('simple_form.labels.emoji_reactions.deny_from_all')
|
||||||
|
|
||||||
= f.simple_fields_for :settings, current_user.settings do |ff|
|
= f.simple_fields_for :settings, current_user.settings do |ff|
|
||||||
.fields-group
|
.fields-group
|
||||||
|
|
|
@ -596,6 +596,7 @@ en:
|
||||||
media_attachments:
|
media_attachments:
|
||||||
title: Media attachments
|
title: Media attachments
|
||||||
ng_words:
|
ng_words:
|
||||||
|
enable_block_emoji_reaction_settings: Enable block emoji reactions settings for users
|
||||||
keywords: Reject keywords
|
keywords: Reject keywords
|
||||||
title: NG words and against spams
|
title: NG words and against spams
|
||||||
relationships:
|
relationships:
|
||||||
|
|
|
@ -595,6 +595,7 @@ ja:
|
||||||
media_attachments:
|
media_attachments:
|
||||||
title: 投稿された画像
|
title: 投稿された画像
|
||||||
ng_words:
|
ng_words:
|
||||||
|
enable_block_emoji_reaction_settings: 各ユーザーにスタンプ機能のブロック設定項目を解放する
|
||||||
keywords: 投稿できないキーワード
|
keywords: 投稿できないキーワード
|
||||||
title: NGワードとスパム
|
title: NGワードとスパム
|
||||||
relationships:
|
relationships:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue