diff options
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/log_helper.rb | 12 | ||||
-rw-r--r-- | app/helpers/moderation_helper.rb | 17 |
2 files changed, 19 insertions, 10 deletions
diff --git a/app/helpers/log_helper.rb b/app/helpers/log_helper.rb index 550ed2c15..6d0fdac13 100644 --- a/app/helpers/log_helper.rb +++ b/app/helpers/log_helper.rb @@ -5,7 +5,7 @@ module LogHelper case action when :create if target.is_a? DomainBlock - LogWorker.perform_async("\xf0\x9f\x9a\xab <#{source}> applied a #{target.severity}#{target.force_sensitive? ? " and force sensitive media" : ''}#{target.reject_media? ? " and reject media" : ''} policy on https://#{target.domain}\u200b.\n\n#{target.reason? ? "Comment: #{target.reason}" : ''}") + LogWorker.perform_async("\xf0\x9f\x9a\xab <#{source}> applied a #{target.severity}#{target.force_sensitive? ? " and force sensitive media" : ''}#{target.reject_media? ? " and reject media" : ''}#{target.reject_unknown? ? " and reject unknown accounts" : ''} policy on https://#{target.domain}\u200b.\n\n#{target.reason? ? "Comment: #{target.reason}" : ''}") elsif target.is_a? EmailDomainBlock LogWorker.perform_async("\u26d4 <#{source}> added a registration block on email domain '#{target.domain}'.") elsif target.is_a? CustomEmoji @@ -26,7 +26,7 @@ module LogHelper when :update if target.is_a? DomainBlock - LogWorker.perform_async("\xf0\x9f\x9a\xab <#{source}> changed the policy on https://#{target.domain} to #{target.severity}#{target.force_sensitive? ? " and force sensitive media" : ''}#{target.reject_media? ? " and reject media" : ''}.\n\n#{target.reason? ? "Comment: #{target.reason}" : ''}") + LogWorker.perform_async("\xf0\x9f\x9a\xab <#{source}> changed the policy on https://#{target.domain} to #{target.severity}#{target.force_sensitive? ? " and force sensitive media" : ''}#{target.reject_media? ? " and reject media" : ''}#{target.reject_unknown? ? " and reject unknown accounts" : ''}.\n\n#{target.reason? ? "Comment: #{target.reason}" : ''}") elsif target.is_a? Status LogWorker.perform_async("\xf0\x9f\x91\x81\xef\xb8\x8f <#{source}> changed visibility flags of post #{TagManager.instance.url_for(target)}\u200b.") elsif target.is_a? CustomEmoji @@ -46,17 +46,21 @@ module LogHelper LogWorker.perform_async("\u26d4 <#{source}> disabled the '#{target.shortcode}' emoji.") end + when :mark_unknown + LogWorker.perform_async("\u2753 <#{source}> marked <#{target.acct}> as an unknown account.\n\n#{reason ? "Comment: #{reason}" : ''}") when :force_sensitive LogWorker.perform_async("\xf0\x9f\x94\x9e <#{source}> forced the media of <#{target.acct}> to be marked sensitive.\n\n#{reason ? "Comment: #{reason}" : ''}") when :force_unlisted LogWorker.perform_async("\xf0\x9f\x94\x89 <#{source}> forced the posts of <#{target.acct}> to be unlisted.\n\n#{reason ? "Comment: #{reason}" : ''}") when :silence - LogWorker.perform_async("\xf0\x9f\x94\x87 <#{source}> silenced <#{target.acct}>'.\n\n#{reason ? "Comment: #{reason}" : ''}") + LogWorker.perform_async("\xf0\x9f\x94\x87 <#{source}> silenced <#{target.acct}>.\n\n#{reason ? "Comment: #{reason}" : ''}") when :suspend LogWorker.perform_async("\u26d4 <#{source}> suspended <#{target.acct}>.\n\n#{reason ? "Comment: #{reason}" : ''}") + when :mark_known + LogWorker.perform_async("\u2705 <#{source}> marked <#{target.acct}> as a known account.\n\n#{reason ? "Comment: #{reason}" : ''}") when :allow_nonsensitive - LogWorker.perform_async("\xf0\x9f\x86\x97 <#{source}> allowed <#{target.acct}> to post media without a sensitive flag.") + LogWorker.perform_async("\xf0\x9f\x86\x97 <#{source}> allowed <#{target.acct}> to post media without a sensitive flag.\n\n#{reason ? "Comment: #{reason}" : ''}") when :allow_public LogWorker.perform_async("\xf0\x9f\x86\x8a <#{source}> allowed <#{target.acct}> to post with public visibility.") when :unsilence diff --git a/app/helpers/moderation_helper.rb b/app/helpers/moderation_helper.rb index fda553c37..2f1561772 100644 --- a/app/helpers/moderation_helper.rb +++ b/app/helpers/moderation_helper.rb @@ -1,7 +1,7 @@ module ModerationHelper include LogHelper - POLICIES = %w(silence unsilence suspend unsuspend force_unlisted allow_public force_sensitive allow_nonsensitive reset) + POLICIES = %w(silence unsilence suspend unsuspend force_unlisted mark_known mark_unknown reject_unknown allow_public force_sensitive allow_nonsensitive reset) EXCLUDED_DOMAINS = %w(tailma.ws monsterpit.net monsterpit.cloud monsterpit.gallery monsterpit.blog) def janitor_account @@ -30,6 +30,10 @@ module ModerationHelper end case policy + when 'mark_unknown', 'reject_unknown' + acct.mark_unknown! + when 'mark_known' + acct.mark_known! when 'silence' acct.silence! when 'unsilence' @@ -52,6 +56,7 @@ module ModerationHelper acct.unsilence! acct.allow_public! acct.allow_nonsensitive! + acct.mark_known! end acct.save @@ -77,7 +82,7 @@ module ModerationHelper true end - def domain_policy(domain, policy, reason = nil, force_sensitive = false, reject_media = false, reject_reports = false) + def domain_policy(domain, policy, reason = nil, force_sensitive: false, reject_unknown: false, reject_media: false, reject_reports: false) return if policy.blank? policy = policy.to_s return false unless policy.in?(POLICIES) @@ -87,10 +92,9 @@ module ModerationHelper return false if domain.in?(EXCLUDED_DOMAINS) - if policy == 'force_sensitive' - policy = 'noop' - force_sensitive = true - end + policy = 'noop' if policy == 'force_sensitive' || policy == 'reject_unknown' + force_sensitive = true if policy == 'force_sensitive' + reject_unknown = true if policy == 'reject_unknown' if policy.in? %w(silence suspend force_unlisted) return false unless domain_exists?(domain) @@ -98,6 +102,7 @@ module ModerationHelper domain_block = DomainBlock.find_or_create_by(domain: domain) domain_block.severity = policy domain_block.force_sensitive = force_sensitive + domain_block.reject_unknown = reject_unknown domain_block.reject_media = reject_media domain_block.reject_reports = reject_reports domain_block.reason = reason.strip if reason && !reason.strip.blank? |