about summary refs log tree commit diff
path: root/app/models/form
diff options
context:
space:
mode:
authorStarfall <us@starfall.systems>2020-10-30 09:55:47 -0500
committerStarfall <us@starfall.systems>2020-10-30 09:55:47 -0500
commit259470ec37dfc5c3d34ed5456adcd3ab1a622a18 (patch)
tree0ed8e47864234419df1133ed7cbac481ea8e12dc /app/models/form
parentab2148ef84c2880465599bd8c80e15378cf0a517 (diff)
parent5a41704f8926d9594c66028ca30dc1fc0f98da3d (diff)
Merge branch 'glitch' into main
Diffstat (limited to 'app/models/form')
-rw-r--r--app/models/form/ip_block_batch.rb31
-rw-r--r--app/models/form/redirect.rb2
2 files changed, 32 insertions, 1 deletions
diff --git a/app/models/form/ip_block_batch.rb b/app/models/form/ip_block_batch.rb
new file mode 100644
index 000000000..f6fe9b593
--- /dev/null
+++ b/app/models/form/ip_block_batch.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+class Form::IpBlockBatch
+  include ActiveModel::Model
+  include Authorization
+  include AccountableConcern
+
+  attr_accessor :ip_block_ids, :action, :current_account
+
+  def save
+    case action
+    when 'delete'
+      delete!
+    end
+  end
+
+  private
+
+  def ip_blocks
+    @ip_blocks ||= IpBlock.where(id: ip_block_ids)
+  end
+
+  def delete!
+    ip_blocks.each { |ip_block| authorize(ip_block, :destroy?) }
+
+    ip_blocks.each do |ip_block|
+      ip_block.destroy
+      log_action :destroy, ip_block
+    end
+  end
+end
diff --git a/app/models/form/redirect.rb b/app/models/form/redirect.rb
index a7961f8e8..19ee9faed 100644
--- a/app/models/form/redirect.rb
+++ b/app/models/form/redirect.rb
@@ -32,7 +32,7 @@ class Form::Redirect
 
   def set_target_account
     @target_account = ResolveAccountService.new.call(acct)
-  rescue Goldfinger::Error, HTTP::Error, OpenSSL::SSL::SSLError, Mastodon::Error
+  rescue Webfinger::Error, HTTP::Error, OpenSSL::SSL::SSLError, Mastodon::Error
     # Validation will take care of it
   end