Skip to content

Commit

Permalink
Override Hyrax mailer to inject tenant ID into contact form submissions
Browse files Browse the repository at this point in the history
Fixes #1230
  • Loading branch information
mjgiarlo committed Jun 21, 2017
1 parent 76748ef commit 0eeb281
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app/mailers/hyrax/contact_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module Hyrax
# Mailer for contacting the administrator
class ContactMailer < HykuMailer
def contact(contact_form)
@contact_form = contact_form
# Check for spam
return if @contact_form.spam?
headers = @contact_form.headers.dup
headers[:subject] << " [#{current_tenant_id}]"
mail(headers)
end

private

def current_tenant_id
Account.find_by(tenant: Apartment::Tenant.current)&.cname || Account.admin_host
end
end
end

0 comments on commit 0eeb281

Please sign in to comment.