This repository has been archived by the owner on Dec 21, 2023. It is now read-only.
forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change e-mail domain blocks to block IPs dynamically (mastodon#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 <[email protected]> * Update app/workers/scheduler/email_domain_block_refresh_scheduler.rb Co-authored-by: Yamagishi Kazutoshi <[email protected]> Co-authored-by: Yamagishi Kazutoshi <[email protected]>
- Loading branch information
Showing
20 changed files
with
325 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 13 additions & 14 deletions
27
app/views/admin/email_domain_blocks/_email_domain_block.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
%tr | ||
%td | ||
%samp= email_domain_block.domain | ||
%td | ||
= table_link_to 'trash', t('admin.email_domain_blocks.delete'), admin_email_domain_block_path(email_domain_block), method: :delete | ||
.batch-table__row | ||
%label.batch-table__row__select.batch-table__row__select--aligned.batch-checkbox | ||
= f.check_box :email_domain_block_ids, { multiple: true, include_hidden: false }, email_domain_block.id | ||
.batch-table__row__content.pending-account | ||
.pending-account__header | ||
%samp= link_to email_domain_block.domain, admin_accounts_path(email: "%@#{email_domain_block.domain}") | ||
|
||
- email_domain_block.children.each do |child_email_domain_block| | ||
%tr | ||
%td | ||
%samp= child_email_domain_block.domain | ||
%span.muted-hint | ||
= surround '(', ')' do | ||
= t('admin.email_domain_blocks.from_html', domain: content_tag(:samp, email_domain_block.domain)) | ||
%td | ||
= table_link_to 'trash', t('admin.email_domain_blocks.delete'), admin_email_domain_block_path(child_email_domain_block), method: :delete | ||
%br/ | ||
|
||
- if email_domain_block.parent.present? | ||
= t('admin.email_domain_blocks.resolved_through_html', domain: content_tag(:samp, email_domain_block.parent.domain)) | ||
• | ||
|
||
= t('admin.email_domain_blocks.attempts_over_week', count: email_domain_block.history.reduce(0) { |sum, day| sum + day.accounts }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.