mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-25 08:39:38 -05:00
26 lines
852 B
Ruby
26 lines
852 B
Ruby
require_dependency 'email/message_builder'
|
|
|
|
class InviteMailer < ActionMailer::Base
|
|
include Email::BuildEmailHelper
|
|
|
|
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
|
|
|
|
end
|
|
|
|
end
|