From 3f1e5d2f8744d5277237d62df8317e84cfb1f874 Mon Sep 17 00:00:00 2001 From: multiple creatures Date: Wed, 17 Jul 2019 17:29:04 -0500 Subject: include skipped in `admin:` output --- app/lib/bangtags.rb | 50 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 11 deletions(-) (limited to 'app/lib') diff --git a/app/lib/bangtags.rb b/app/lib/bangtags.rb index 150150f75..8c4517acb 100644 --- a/app/lib/bangtags.rb +++ b/app/lib/bangtags.rb @@ -518,13 +518,12 @@ class Bangtags @status.visibility = :direct @status.local_only = true @status.content_type = 'text/markdown' - chunk = "\n# #!admin:#{cmd[1].downcase}:\n
\n" + @chunks << "\n# #!admin:#{cmd[1].downcase}:\n
\n" case cmd[1].downcase when 'silence', 'unsilence', 'suspend', 'unsuspend', 'forgive' @tf_cmds.push(cmd) @component_stack.push(:tf) when 'exec', 'eval' - @chunks << chunk unless @account.username.in?((ENV['ALLOW_ADMIN_EVAL_FROM'] || '').split) @chunks << "Unauthorized." next @@ -563,20 +562,30 @@ class Bangtags if c.start_with?('@') parts = c.split('@')[1..2] a = Account.find_by(username: parts[0], domain: parts[1]) - next if a.nil? + if a.nil? || a.id == @account.id + output << "Skipped @#{parts.join('@')}." + next + end output << "Silenced @#{parts.join('@')}." Admin::ActionLog.create(account: @account, action: :silence, target: a) a.silence! a.save elsif c.match?(/^[\w\-]+\.[\w\-]+(?:\.[\w\-]+)*$/) c.downcase! - next if c.end_with?('monsterpit.net', 'tailma.ws') + if c.end_with?('monsterpit.net', 'tailma.ws') + output << "Skipped #{c}." + next + end begin code = Request.new(:head, "https://#{c}").perform(&:code) rescue + output << "Skipped #{c}." + next + end + if [404, 410].include?(code) + output << "Skipped #{c}." next end - next if [404, 410].include?(code) domain_block = DomainBlock.find_or_create_by(domain: c) domain_block.severity = "silence" domain_block.save @@ -592,7 +601,10 @@ class Bangtags if c.start_with?('@') parts = c.split('@')[1..2] a = Account.find_by(username: parts[0], domain: parts[1]) - next if a.nil? + if a.nil? || a.id == @account.id + output << "Skipped @#{parts.join('@')}." + next + end output << "Reset policy for @#{parts.join('@')}." Admin::ActionLog.create(account: @account, action: :unsilence, target: a) a.unsilence! @@ -601,9 +613,15 @@ class Bangtags a.save elsif c.match?(/^[\w\-]+\.[\w\-]+(?:\.[\w\-]+)*$/) c.downcase! - next if c.end_with?('monsterpit.net', 'tailma.ws') + if c.end_with?('monsterpit.net', 'tailma.ws') + output << "Skipped #{c}." + next + end domain_block = DomainBlock.find_by(domain: c) - next if domain_block.nil? + if domain_block.nil? + output << "Skipped #{c}." + next + end output << "Reset policy for #{c}." Admin::ActionLog.create(account: @account, action: :destroy, target: domain_block) UnblockDomainService.new.call(domain_block) @@ -616,19 +634,29 @@ class Bangtags if c.start_with?('@') parts = c.split('@')[1..2] a = Account.find_by(username: parts[0], domain: parts[1]) - next if a.nil? + if a.nil? || a.id == @account.id + output << "Skipped @#{parts.join('@')}." + next + end output << "Suspended @#{parts.join('@')}." Admin::ActionLog.create(account: @account, action: :suspend, target: a) SuspendAccountService.new.call(a, include_user: true) elsif c.match?(/\A[\w\-]+\.[\w\-]+(?:\.[\w\-]+)*\Z/) c.downcase! - next if c.end_with?('monsterpit.net', 'tailma.ws') + if c.end_with?('monsterpit.net', 'tailma.ws') + output << "Skipped #{c}." + next + end begin code = Request.new(:head, "https://#{c}").perform(&:code) rescue + output << "Skipped #{c}." + next + end + if [404, 410].include?(code) + output << "Skipped #{c}." next end - next if [404, 410].include?(code) domain_block = DomainBlock.find_or_create_by(domain: c) domain_block.severity = "suspend" domain_block.reject_media = true -- cgit