dmails: send automated dmails from Danbooru.config.system_user.
Sends automated dmails from `Danbooru.config.system_user`, rather than whichever user is performing the action happens to be (usually User.admins.first). Also adds a notice in the view that the dmail was automated.
This commit is contained in:
@@ -45,20 +45,24 @@ class Dmail < ActiveRecord::Base
|
||||
copy = nil
|
||||
|
||||
Dmail.transaction do
|
||||
# recipient's copy
|
||||
copy = Dmail.new(params)
|
||||
copy.owner_id = copy.to_id
|
||||
unless copy.to_id == CurrentUser.id
|
||||
copy.save
|
||||
end
|
||||
copy.save unless copy.to_id == copy.from_id
|
||||
|
||||
# sender's copy
|
||||
copy = Dmail.new(params)
|
||||
copy.owner_id = CurrentUser.id
|
||||
copy.owner_id = copy.from_id
|
||||
copy.is_read = true
|
||||
copy.save
|
||||
end
|
||||
|
||||
copy
|
||||
end
|
||||
|
||||
def create_automated(params)
|
||||
create_split(from: Danbooru.config.system_user, **params)
|
||||
end
|
||||
end
|
||||
|
||||
def build_response(options = {})
|
||||
@@ -186,6 +190,10 @@ class Dmail < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def is_automated?
|
||||
from == Danbooru.config.system_user
|
||||
end
|
||||
|
||||
def filtered?
|
||||
CurrentUser.dmail_filter.try(:filtered?, self)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user