jam-cloud/ruby/lib/jam_ruby/app/mailers/batch_mailer.rb

242 lines
7.1 KiB
Ruby

module JamRuby
class BatchMailer < ActionMailer::Base
include SendGrid
layout "batch_mailer"
DEFAULT_SENDER = "support@jamkazam.com"
default :from => DEFAULT_SENDER
sendgrid_category :batch_email
sendgrid_category :use_subject_lines
sendgrid_unique_args :env => Environment.mode
def send_batch_email(user, signup_confirm_url)
@user = user
@signup_confirm_url = signup_confirm_url
sendgrid_category "Confirm Email"
sendgrid_unique_args :type => "confirm_email"
mail(:to => user.email, :subject => "Please confirm your JamKazam email") do |format|
format.text
format.html
end
end
def welcome_message(user)
@user = user
sendgrid_category "Welcome"
sendgrid_unique_args :type => "welcome_message"
mail(:to => user.email, :subject => "Welcome to JamKazam") do |format|
format.text
format.html
end
end
def password_changed(user)
@user = user
sendgrid_unique_args :type => "password_changed"
mail(:to => user.email, :subject => "JamKazam Password Changed") do |format|
format.text
format.html
end
end
def password_reset(user, password_reset_url)
@user = user
@password_reset_url = password_reset_url
sendgrid_unique_args :type => "password_reset"
mail(:to => user.email, :subject => "JamKazam Password Reset") do |format|
format.text
format.html
end
end
def updating_email(user)
@user = user
sendgrid_unique_args :type => "updating_email"
mail(:to => user.update_email, :subject => "JamKazam Email Change Confirmation") do |format|
format.text
format.html
end
end
def updated_email(user)
@user = user
sendgrid_unique_args :type => "updated_email"
mail(:to => user.email, :subject => "JamKazam Email Changed") do |format|
format.text
format.html
end
end
def new_musicians(user, new_nearby, host='www.jamkazam.com')
@user, @new_nearby, @host = user, new_nearby, host
sendgrid_unique_args :type => "new_musicians"
mail(:to => user.email, :subject => "JamKazam New Musicians in Your Area") do |format|
format.text
format.html
end
end
#################################### NOTIFICATION EMAILS ####################################
def friend_request(email, msg)
subject = "You have a new friend request on JamKazam"
unique_args = {:type => "friend_request"}
@body = msg
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:to => email, :subject => subject) do |format|
format.text
format.html
end
end
def friend_request_accepted(email, msg)
subject = "You have a new friend on JamKazam"
unique_args = {:type => "friend_request_accepted"}
@body = msg
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:to => email, :subject => subject) do |format|
format.text
format.html
end
end
def new_user_follower(email, msg)
subject = "You have a new follower on JamKazam"
unique_args = {:type => "new_user_follower"}
@body = msg
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:to => email, :subject => subject) do |format|
format.text
format.html
end
end
def new_band_follower(email, msg)
subject = "Your band has a new follower on JamKazam"
unique_args = {:type => "new_band_follower"}
@body = msg
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:bcc => email, :subject => subject) do |format|
format.text
format.html
end
end
def session_invitation(email, msg)
subject = "You have been invited to a session on JamKazam"
unique_args = {:type => "session_invitation"}
@body = msg
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:to => email, :subject => subject) do |format|
format.text
format.html
end
end
def musician_session_join(email, msg, session_id)
subject = "Someone you know is in a session on JamKazam"
unique_args = {:type => "musician_session_join"}
@body = msg
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session_id}"
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:bcc => email, :subject => subject) do |format|
format.text
format.html
end
end
def band_session_join(email, msg, session_id)
subject = "A band that you follow has joined a session"
unique_args = {:type => "band_session_join"}
@body = msg
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session_id}"
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:bcc => email, :subject => subject) do |format|
format.text
format.html
end
end
def musician_recording_saved(email, msg)
subject = "A musician has saved a new recording on JamKazam"
unique_args = {:type => "musician_recording_saved"}
@body = msg
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:bcc => email, :subject => subject) do |format|
format.text
format.html
end
end
def band_recording_saved(email, msg)
subject = "A band has saved a new recording on JamKazam"
unique_args = {:type => "band_recording_saved"}
@body = msg
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:bcc => email, :subject => subject) do |format|
format.text
format.html
end
end
def band_invitation(email, msg)
subject = "You have been invited to join a band on JamKazam"
unique_args = {:type => "band_invitation"}
@body = msg
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:to => email, :subject => subject) do |format|
format.text
format.html
end
end
def band_invitation_accepted(email, msg)
subject = "Your band invitation was accepted"
unique_args = {:type => "band_invitation_accepted"}
@body = msg
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:to => email, :subject => subject) do |format|
format.text
format.html
end
end
# def send_notification(email, subject, msg, unique_args)
# @body = msg
# sendgrid_category "Notification"
# sendgrid_unique_args :type => unique_args[:type]
# mail(:bcc => email, :subject => subject) do |format|
# format.text
# format.html
# end
# end
#############################################################################################
end
end