1 class Notifier < ActionMailer::Base
2 def signup_confirm(user, token)
4 subject I18n.t('notifier.signup_confirm.subject')
5 body :url => url_for(:host => SERVER_URL,
6 :controller => "user", :action => "confirm",
7 :display_name => user.display_name,
8 :confirm_string => token.token)
11 def email_confirm(user, token)
13 recipients user.new_email
14 subject I18n.t('notifier.email_confirm.subject')
15 body :address => user.new_email,
16 :url => url_for(:host => SERVER_URL,
17 :controller => "user", :action => "confirm_email",
18 :confirm_string => token.token)
21 def lost_password(user, token)
23 subject I18n.t('notifier.lost_password.subject')
24 body :url => url_for(:host => SERVER_URL,
25 :controller => "user", :action => "reset_password",
26 :token => token.token)
29 def gpx_success(trace, possible_points)
30 common_headers trace.user
31 subject I18n.t('notifier.gpx_notification.success.subject')
32 body :trace_name => trace.name,
33 :trace_points => trace.size,
34 :trace_description => trace.description,
35 :trace_tags => trace.tags,
36 :possible_points => possible_points
39 def gpx_failure(trace, error)
40 common_headers trace.user
41 from "webmaster@openstreetmap.org"
42 subject I18n.t('notifier.gpx_notification.failure.subject')
43 body :trace_name => trace.name,
44 :trace_description => trace.description,
45 :trace_tags => trace.tags,
49 def message_notification(message)
50 common_headers message.recipient
51 from_header message.sender.display_name, "m", message.id, message.digest
52 subject I18n.t('notifier.message_notification.subject_header', :subject => message.title, :locale => locale)
53 body :to_user => message.recipient.display_name,
54 :from_user => message.sender.display_name,
55 :body => message.body,
56 :title => message.title,
57 :readurl => url_for(:host => SERVER_URL,
58 :controller => "message", :action => "read",
59 :message_id => message.id),
60 :replyurl => url_for(:host => SERVER_URL,
61 :controller => "message", :action => "reply",
62 :message_id => message.id)
65 def diary_comment_notification(comment)
66 common_headers comment.diary_entry.user
67 from_header comment.user.display_name, "c", comment.id, comment.digest
68 subject I18n.t('notifier.diary_comment_notification.subject', :user => comment.user.display_name, :locale => locale)
69 body :to_user => comment.diary_entry.user.display_name,
70 :from_user => comment.user.display_name,
71 :body => comment.body,
72 :title => comment.diary_entry.title,
73 :readurl => url_for(:host => SERVER_URL,
74 :controller => "diary_entry",
76 :display_name => comment.diary_entry.user.display_name,
77 :id => comment.diary_entry.id,
78 :anchor => "comment#{comment.id}"),
79 :commenturl => url_for(:host => SERVER_URL,
80 :controller => "diary_entry",
82 :display_name => comment.diary_entry.user.display_name,
83 :id => comment.diary_entry.id,
84 :anchor => "newcomment"),
85 :replyurl => url_for(:host => SERVER_URL,
86 :controller => "message",
88 :display_name => comment.user.display_name,
89 :title => "Re: #{comment.diary_entry.title}")
92 def friend_notification(friend)
93 common_headers friend.befriendee
94 subject I18n.t('notifier.friend_notification.subject', :user => friend.befriender.display_name, :locale => locale)
95 body :friend => friend
98 def note_comment_notification(comment, recipient)
99 common_headers recipient
100 owner = (recipient == comment.note.author);
101 subject I18n.t('notifier.note_plain.subject_own', :commenter => comment.author_name) if owner
102 subject I18n.t('notifier.note_plain.subject_other', :commenter => comment.author_name) unless owner
104 body :nodeurl => url_for(:host => SERVER_URL,
105 :controller => "browse",
107 :id => comment.note_id),
108 :place => comment.note.nearby_place,
109 :comment => comment.body,
111 :commenter => comment.author_name
116 def common_headers(recipient)
117 recipients recipient.email
118 locale recipient.preferred_language_from(I18n.available_locales)
120 headers "return-path" => EMAIL_RETURN_PATH,
121 "Auto-Submitted" => "auto-generated"
124 def from_header(name, type, id, digest)
125 if domain = MESSAGES_DOMAIN
126 from quote_address_if_necessary("#{name} <#{type}-#{id}-#{digest[0,6]}@#{domain}>", "utf-8")