discourse/app/mailers/invite_mailer.rb

27 lines
852 B
Ruby
Raw Normal View History

require_dependency 'email/message_builder'
2013-02-06 03:16:51 +08:00
class InviteMailer < ActionMailer::Base
include Email::BuildEmailHelper
2013-02-07 23:45:24 +08:00
2013-02-06 03:16:51 +08:00
def send_invite(invite)
# Find the first topic they were invited to
first_topic = invite.topics.order(:created_at).first
# If they were invited to a topic
if first_topic.present?
build_email(invite.email,
template: 'invite_mailer',
invitee_name: invite.invited_by.username,
invite_link: "#{Discourse.base_url}/invites/#{invite.invite_key}",
topic_title: first_topic.try(:title))
else
build_email(invite.email,
template: 'invite_forum_mailer',
invitee_name: invite.invited_by.username,
invite_link: "#{Discourse.base_url}/invites/#{invite.invite_key}")
end
2013-02-06 03:16:51 +08:00
end
end