emails: add /emails index page.
Add emails index page at https://danbooru.donmai.us/emails. Mods can use this page to view and search emails belonging to users below mod level.
This commit is contained in:
@@ -10,6 +10,14 @@ class EmailAddress < ApplicationRecord
|
||||
validate :validate_deliverable, on: :deliverable
|
||||
after_save :update_user
|
||||
|
||||
def self.visible(user)
|
||||
if user.is_moderator?
|
||||
where(user: User.where("level < ?", user.level)).or(where(user: user))
|
||||
else
|
||||
none
|
||||
end
|
||||
end
|
||||
|
||||
def address=(value)
|
||||
self.normalized_address = EmailValidator.normalize(value) || address
|
||||
super
|
||||
@@ -29,6 +37,15 @@ class EmailAddress < ApplicationRecord
|
||||
user.update!(is_verified: is_verified? && nondisposable?)
|
||||
end
|
||||
|
||||
def self.search(params)
|
||||
q = super
|
||||
|
||||
q = q.search_attributes(params, :user, :address, :normalized_address, :is_verified, :is_deliverable)
|
||||
q = q.apply_default_order(params)
|
||||
|
||||
q
|
||||
end
|
||||
|
||||
concerning :VerificationMethods do
|
||||
def verifier
|
||||
@verifier ||= Danbooru::MessageVerifier.new(:email_verification_key)
|
||||
|
||||
Reference in New Issue
Block a user