2013-06-10 16:46:08 -04:00
|
|
|
require_dependency 'email/message_builder'
|
2013-02-05 14:16:51 -05:00
|
|
|
|
|
|
|
class InviteMailer < ActionMailer::Base
|
2013-06-10 16:46:08 -04:00
|
|
|
include Email::BuildEmailHelper
|
2013-02-07 10:45:24 -05:00
|
|
|
|
2013-02-05 14:16:51 -05: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
|
2013-11-06 12:56:26 -05:00
|
|
|
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}",
|
2014-06-14 18:49:19 -04:00
|
|
|
topic_title: first_topic.try(:title),
|
|
|
|
site_description: SiteSetting.site_description,
|
|
|
|
site_title: SiteSetting.title)
|
2013-11-06 12:56:26 -05:00
|
|
|
else
|
|
|
|
build_email(invite.email,
|
|
|
|
template: 'invite_forum_mailer',
|
|
|
|
invitee_name: invite.invited_by.username,
|
2014-06-14 18:49:19 -04:00
|
|
|
invite_link: "#{Discourse.base_url}/invites/#{invite.invite_key}",
|
|
|
|
site_description: SiteSetting.site_description,
|
|
|
|
site_title: SiteSetting.title)
|
2013-11-06 12:56:26 -05:00
|
|
|
end
|
|
|
|
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|