mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-22 12:55:56 +01:00
Add EmailDomainBlock.parents
scope (#31968)
This commit is contained in:
parent
6ae1fcd059
commit
697947116e
3 changed files with 6 additions and 4 deletions
|
@ -5,7 +5,7 @@ module Admin
|
|||
def index
|
||||
authorize :email_domain_block, :index?
|
||||
|
||||
@email_domain_blocks = EmailDomainBlock.where(parent_id: nil).includes(:children).order(id: :desc).page(params[:page])
|
||||
@email_domain_blocks = EmailDomainBlock.parents.includes(:children).order(id: :desc).page(params[:page])
|
||||
@form = Form::EmailDomainBlockBatch.new
|
||||
end
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@ class EmailDomainBlock < ApplicationRecord
|
|||
|
||||
validates :domain, presence: true, uniqueness: true, domain: true
|
||||
|
||||
scope :parents, -> { where(parent_id: nil) }
|
||||
|
||||
# Used for adding multiple blocks at once
|
||||
attr_accessor :other_domains
|
||||
|
||||
|
|
|
@ -7,11 +7,11 @@ module Mastodon::CLI
|
|||
class EmailDomainBlocks < Base
|
||||
desc 'list', 'List blocked e-mail domains'
|
||||
def list
|
||||
EmailDomainBlock.where(parent_id: nil).find_each do |entry|
|
||||
say(entry.domain.to_s, :white)
|
||||
EmailDomainBlock.parents.find_each do |parent|
|
||||
say(parent.domain.to_s, :white)
|
||||
|
||||
shell.indent do
|
||||
EmailDomainBlock.where(parent_id: entry.id).find_each do |child|
|
||||
EmailDomainBlock.where(parent_id: parent.id).find_each do |child|
|
||||
say(child.domain, :cyan)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue