-
Notifications
You must be signed in to change notification settings - Fork 0
/
mailer.rb
35 lines (28 loc) · 1 KB
/
mailer.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require 'action_mailer'
# compose and send email notifications
class Mailer < ActionMailer::Base
def notification(to:, from:, subject:, view_args:)
@worker_diff = view_args[:worker_diff] || 'N/A'
@footer_timestamp = footstamp
mail_with_format(to: to, from: from, subject: subject)
end
def daily_summary(to:, from:, subject:, view_args:)
@worker_diff = view_args[:worker_diff] || 'N/A'
@current_hashrate = view_args[:current_hashrate] || 'N/A'
@avg_hashrate = view_args[:avg_hashrate] || 'N/A'
@usd_per_day = view_args[:usd_per_day] || 'N/A'
@usd_per_month = view_args[:usd_per_month] || 'N/A'
@footer_timestamp = footstamp
mail_with_format(to: to, from: from, subject: subject)
end
private
def footstamp
Time.now.strftime('%m/%d/%Y%l:%M:%S %p %Z') # timestamp for footer of email to prevent trimming
end
def mail_with_format(to:, from:, subject:)
mail(to: to, from: from, subject: subject) do |format|
format.text
format.html
end
end
end