1 class Notifier < ActionMailer::Base
2 default :from => EMAIL_FROM,
3 :return_path => EMAIL_RETURN_PATH,
4 :auto_submitted => "auto-generated"
6 def signup_confirm(user, token)
7 @locale = user.preferred_language_from(I18n.available_locales)
8 @url = url_for(:host => SERVER_URL,
9 :controller => "user", :action => "confirm",
10 :display_name => user.display_name,
11 :confirm_string => token.token)
13 mail :to => user.email,
14 :subject => I18n.t('notifier.signup_confirm.subject', :locale => @locale)
17 def email_confirm(user, token)
18 @locale = user.preferred_language_from(I18n.available_locales)
19 @address = user.new_email
20 @url = url_for(:host => SERVER_URL,
21 :controller => "user", :action => "confirm_email",
22 :confirm_string => token.token)
24 mail :to => user.new_email,
25 :subject => I18n.t('notifier.email_confirm.subject', :locale => @locale)
28 def lost_password(user, token)
29 @locale = user.preferred_language_from(I18n.available_locales)
30 @url = url_for(:host => SERVER_URL,
31 :controller => "user", :action => "reset_password",
32 :token => token.token)
34 mail :to => user.email,
35 :subject => I18n.t('notifier.lost_password.subject', :locale => @locale)
38 def gpx_success(trace, possible_points)
39 @locale = trace.user.preferred_language_from(I18n.available_locales)
40 @trace_name = trace.name
41 @trace_points = trace.size
42 @trace_description = trace.description
43 @trace_tags = trace.tags
44 @possible_points = possible_points
46 mail :to => trace.user.email,
47 :subject => I18n.t('notifier.gpx_notification.success.subject', :locale => @locale)
50 def gpx_failure(trace, error)
51 @locale = trace.user.preferred_language_from(I18n.available_locales)
52 @trace_name = trace.name
53 @trace_description = trace.description
54 @trace_tags = trace.tags
57 mail :to => trace.user.email,
58 :subject => I18n.t('notifier.gpx_notification.failure.subject', :locale => @locale)
61 def message_notification(message)
62 @locale = message.recipient.preferred_language_from(I18n.available_locales)
63 @to_user = message.recipient.display_name
64 @from_user = message.sender.display_name
66 @title = message.title
67 @readurl = url_for(:host => SERVER_URL,
68 :controller => "message", :action => "read",
69 :message_id => message.id)
70 @replyurl = url_for(:host => SERVER_URL,
71 :controller => "message", :action => "reply",
72 :message_id => message.id)
74 mail :from => from_address(message.sender.display_name, "m", message.id, message.digest),
75 :to => message.recipient.email,
76 :subject => I18n.t('notifier.message_notification.subject_header', :subject => message.title, :locale => @locale)
79 def diary_comment_notification(comment)
80 @locale = comment.diary_entry.user.preferred_language_from(I18n.available_locales)
81 @to_user = comment.diary_entry.user.display_name
82 @from_user = comment.user.display_name
84 @title = comment.diary_entry.title
85 @readurl = url_for(:host => SERVER_URL,
86 :controller => "diary_entry",
88 :display_name => comment.diary_entry.user.display_name,
89 :id => comment.diary_entry.id,
90 :anchor => "comment#{comment.id}")
91 @commenturl = url_for(:host => SERVER_URL,
92 :controller => "diary_entry",
94 :display_name => comment.diary_entry.user.display_name,
95 :id => comment.diary_entry.id,
96 :anchor => "newcomment")
97 @replyurl = url_for(:host => SERVER_URL,
98 :controller => "message",
100 :display_name => comment.user.display_name,
101 :title => "Re: #{comment.diary_entry.title}")
103 mail :from => from_address(comment.user.display_name, "c", comment.id, comment.digest),
104 :to => comment.diary_entry.user.email,
105 :subject => I18n.t('notifier.diary_comment_notification.subject', :user => comment.user.display_name, :locale => @locale)
108 def friend_notification(friend)
109 @locale = friend.befriendee.preferred_language_from(I18n.available_locales)
112 mail :to => friend.befriendee.email,
113 :subject => I18n.t('notifier.friend_notification.subject', :user => friend.befriender.display_name, :locale => @locale)
118 def from_address(name, type, id, digest)
119 if domain = MESSAGES_DOMAIN
120 "#{name} <#{type}-#{id}-#{digest[0,6]}@#{domain}>"