added 260907 version of worker toolkit
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
class ApplicationMailer < ActionMailer::Base
|
||||
default from: Rails.application.secrets.smtp_email_from
|
||||
|
||||
REGEXP = /\A\s*([-\p{L}\d+._]{1,64})@((?:[-\p{L}\d]+\.)+\p{L}{2,})\s*\z/i
|
||||
|
||||
def valid_email?(email)
|
||||
email =~ REGEXP
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,21 @@
|
||||
class CheckinReminderMailer < ApplicationMailer
|
||||
layout "mailer_layout"
|
||||
|
||||
def remind(notification_hash)
|
||||
@email = notification_hash[:email]
|
||||
return unless valid_email?(@email)
|
||||
|
||||
user = User.find_by(email: @email)
|
||||
notify_token = user&.notify_token
|
||||
|
||||
return unless notify_token
|
||||
return if user&.rejected_type.present? # Rejected via AWS SES
|
||||
|
||||
@click_here_link = Rails.application.secrets.base_url
|
||||
@unsubscribe_link =
|
||||
Rails.application.secrets.base_url + "/unsubscribe/#{User.find_by(email: @email).notify_token}?stop_remind"
|
||||
attachments.inline["optional_email_img.png"] = File.read("public/images/optional_email_img.png")
|
||||
|
||||
mail(to: @email, subject: I18n.t("checkin_reminder_mailer.subject"))
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,23 @@
|
||||
class NotificationsMailer < ApplicationMailer
|
||||
layout "mailer_layout"
|
||||
|
||||
helper_method :resource_title, :resource_url
|
||||
|
||||
def notify(notification_hash)
|
||||
@email = notification_hash[:email]
|
||||
return unless valid_email?(@email)
|
||||
|
||||
@unsubscribe_link = Rails.application.secrets.base_url + "/unsubscribe/#{User.find_by(email: @email).notify_token}"
|
||||
@data = notification_hash[:data]
|
||||
|
||||
mail(to: @email, subject: "New response to your Flaredown message")
|
||||
end
|
||||
|
||||
def resource_title(object_id, class_name = "Post")
|
||||
class_name.constantize.find(object_id).title.to_s
|
||||
end
|
||||
|
||||
def resource_url(object_id, class_name = "Post")
|
||||
[ENV["BASE_URL"], class_name.tableize, object_id].map(&:to_s).join("/")
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,12 @@
|
||||
class PromotionRate::LowRateMailer < ApplicationMailer
|
||||
layout "mailer_layout"
|
||||
|
||||
def show(email, objects, start_date, end_date)
|
||||
@email = email
|
||||
@objects = objects
|
||||
@start_date = start_date
|
||||
@end_date = end_date
|
||||
|
||||
mail(to: @email, subject: I18n.t("promotion_rate.low_rate.subject"))
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,12 @@
|
||||
class PromotionRate::StatisticMailer < ApplicationMailer
|
||||
layout "mailer_layout"
|
||||
|
||||
def show(email, objects, start_date, end_date)
|
||||
@email = email
|
||||
@objects = objects
|
||||
@start_date = start_date
|
||||
@end_date = end_date
|
||||
|
||||
mail(to: @email, subject: I18n.t("promotion_rate.statistic.subject"))
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
class TopPostsMailer < ApplicationMailer
|
||||
layout "mailer_layout"
|
||||
|
||||
def notify(mailer_hash)
|
||||
@email = mailer_hash[:email]
|
||||
return unless valid_email?(@email)
|
||||
|
||||
@unsubscribe_link =
|
||||
Rails.application.secrets.base_url + "/unsubscribe/#{mailer_hash[:notify_token]}?notify_top_posts=false"
|
||||
@top_posts = Post.where(:_type => "Post", :_id.in => mailer_hash[:top_posts_ids])
|
||||
|
||||
mail(to: @email, subject: 'Weekly "top posts"')
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
class UserDataMailer < ApplicationMailer
|
||||
def trackings_csv(email, csv_data)
|
||||
attachments["data.csv"] = csv_data
|
||||
|
||||
mail to: email
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user