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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
class Notifications < ActionMailer::Base
default from: "admin@example.com"
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.notifications.new_pin.subject
#
def new_pin(conference)
@conference = conference
@pin = Hash.new()
if conference.conferenceable_type == 'User'
user = conference.conferenceable
if ! user.first_name.blank?
@pin[:greeting] = user.first_name
else
@pin[:greeting] = user.user_name
end
else
@pin[:greeting] = conference.conferenceable.to_s
end
@pin[:conference] = conference.to_s
@pin[:pin] = conference.pin
@pin[:phone_numbers] = conference.phone_numbers.join(', ')
mail(from: Tenant.find(GsParameter.get('DEFAULT_API_TENANT_ID')).from_field_pin_change_email,to: "#{conference.conferenceable.email}", :subject => "Conference PIN changed: #{@pin[:conference]}")
end
def new_password(user, password)
@password = password
@message = Hash.new()
if ! user.first_name.blank?
@message[:greeting] = user.first_name
else
@message[:greeting] = user.user_name
end
mail(from: Tenant.find(GsParameter.get('DEFAULT_API_TENANT_ID')).from_field_pin_change_email, to: "#{user.email}", :subject => "Password recovery")
end
def new_voicemail(freeswitch_voicemail_msg, attach_file = false)
sip_account = SipAccount.find_by_auth_name(freeswitch_voicemail_msg.username)
user = sip_account.sip_accountable
@voicemail = Hash.new()
if ! user.first_name.blank?
@voicemail[:greeting] = user.first_name
else
@voicemail[:greeting] = user.user_name
end
@voicemail[:destination] = freeswitch_voicemail_msg.in_folder
@voicemail[:from] = "#{freeswitch_voicemail_msg.cid_number} #{freeswitch_voicemail_msg.cid_name}"
@voicemail[:to] = sip_account.to_s
@voicemail[:date] = Time.at(freeswitch_voicemail_msg.created_epoch).getlocal.to_s
@voicemail[:duration] = Time.at(freeswitch_voicemail_msg.message_len).utc.strftime('%T')
if attach_file
caller_number = freeswitch_voicemail_msg.cid_number.gsub(/[^0-9]/, '')
if caller_number.blank?
caller_number = 'anonymous'
end
attachments["#{Time.at(freeswitch_voicemail_msg.created_epoch).getlocal.strftime('%Y%m%d-%H%M%S')}-#{caller_number}.wav"] = File.read(freeswitch_voicemail_msg.file_path)
end
mail(from: Tenant.find(GsParameter.get('DEFAULT_API_TENANT_ID')).from_field_voicemail_email, to: "#{user.email}", :subject => "New Voicemail from #{@voicemail[:from]}, received #{Time.at(freeswitch_voicemail_msg.created_epoch).getlocal.to_s}")
end
def new_fax(fax_document)
fax_account = fax_document.fax_account
if !fax_account || fax_account.email.blank?
return false
end
caller_number = fax_document.caller_id_number.gsub(/[^0-9]/, '')
if caller_number.blank?
caller_number = 'anonymous'
end
@fax = {
:greeting => '',
:account_name => fax_account.name,
:from => "#{caller_number} #{fax_document.caller_id_name}",
:remote_station_id => fax_document.remote_station_id,
:local_station_id => fax_document.local_station_id,
:date => fax_document.created_at,
}
if fax_account.fax_accountable
if fax_account.fax_accountable_type == 'User'
user = fax_account.fax_accountable
if ! user.first_name.blank?
@fax[:greeting] = user.first_name
else
@fax[:greeting] = user.user_name
end
elsif fax_account.fax_accountable_type == 'Tenant'
@fax[:greeting] = fax_account.fax_accountable.name
end
end
attachments["#{fax_document.created_at.strftime('%Y%m%d-%H%M%S')}-#{caller_number}.pdf"] = File.read(fax_document.document.path)
mail(from: Tenant.find(GsParameter.get('DEFAULT_API_TENANT_ID')).from_field_voicemail_email, to: "#{fax_account.email}", :subject => "New Fax Document from #{@fax[:from]}, received #{fax_document.created_at}")
end
end
|