Send pm instead of email on invite disable

This commit is contained in:
nyanpasu 2016-05-19 08:59:59 +08:00
parent 19526c2d3f
commit 99f78ad10c
3 changed files with 11 additions and 23 deletions

View file

@ -1,16 +0,0 @@
class DisableInviteNotification < ActionMailer::Base
default :from => "#{Rails.application.name} " <<
"<nobody@#{Rails.application.domain}>"
def notify(user, mod, reason)
@mod = mod
@reason = reason
mail(
:from => "#{@mod.username} <nobody@#{Rails.application.domain}>",
:replyto => "#{@mod.username} <#{@mod.email}>",
:to => user.email,
:subject => "[#{Rails.application.name}] Your invite privileges have been removed"
)
end
end

View file

@ -115,7 +115,17 @@ class User < ActiveRecord::Base
self.disabled_invite_by_user_id = disabler.id
self.disabled_invite_reason = reason
DisableInviteNotification.notify(self, disabler, reason)
msg = Message.new
msg.deleted_by_author = true
msg.author_user_id = disabler.id
msg.recipient_user_id = self.id
msg.subject = "Your invite privileges have been revoked"
msg.body = "The reason given:\n" <<
"\n" <<
"> *#{reason}*\n" <<
"\n" <<
"*This is an automated message.*"
msg.save
m = Moderation.new
m.moderator_user_id = disabler.id

View file

@ -1,6 +0,0 @@
Invitations have been disabled for you on <%= Rails.application.name %> by <%= @mod.username %> for:
<%= word_wrap(@reason, :line_width => 72).gsub(/\n/, "\n ") %>
You can no longer allowed send invites. If you wish, you can discuss this with
the moderator by replying to this e-mail.