diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2022-02-24 17:28:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-24 17:28:23 +0100 |
commit | a29a982eaa0536a741b43ffb3397c74e3abe7196 (patch) | |
tree | 12d9852def5f0ac7f1fe03e51113a65bafa68e8e /app/models/form | |
parent | 91cc8d1e636a3515b15758d0ad449a0477ea8c4c (diff) |
Change e-mail domain blocks to block IPs dynamically (#17635)
* Change e-mail domain blocks to block IPs dynamically * Update app/workers/scheduler/email_domain_block_refresh_scheduler.rb Co-authored-by: Yamagishi Kazutoshi <ykzts@desire.sh> * Update app/workers/scheduler/email_domain_block_refresh_scheduler.rb Co-authored-by: Yamagishi Kazutoshi <ykzts@desire.sh> Co-authored-by: Yamagishi Kazutoshi <ykzts@desire.sh>
Diffstat (limited to 'app/models/form')
-rw-r--r-- | app/models/form/email_domain_block_batch.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/app/models/form/email_domain_block_batch.rb b/app/models/form/email_domain_block_batch.rb new file mode 100644 index 000000000..df120182b --- /dev/null +++ b/app/models/form/email_domain_block_batch.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +class Form::EmailDomainBlockBatch + include ActiveModel::Model + include Authorization + include AccountableConcern + + attr_accessor :email_domain_block_ids, :action, :current_account + + def save + case action + when 'delete' + delete! + end + end + + private + + def email_domain_blocks + @email_domain_blocks ||= EmailDomainBlock.where(id: email_domain_block_ids) + end + + def delete! + email_domain_blocks.each do |email_domain_block| + authorize(email_domain_block, :destroy?) + email_domain_block.destroy! + log_action :destroy, email_domain_block + end + end +end |