Mark mails as auto submitted. Closes #627.
[rails.git] / app / models / notifier.rb
1 class Notifier < ActionMailer::Base
2   def signup_confirm(user, token)
3     recipients user.email
4     from "webmaster@openstreetmap.org"
5     subject "[OpenStreetMap] Confirm your email address"
6     headers "Auto-Submitted" => "auto-generated"
7     body :url => url_for(:host => SERVER_URL,
8                          :controller => "user", :action => "confirm",
9                          :confirm_string => token.token)
10   end
11
12   def lost_password(user, token)
13     recipients user.email
14     from "webmaster@openstreetmap.org"
15     subject "[OpenStreetMap] Password reset request"
16     headers "Auto-Submitted" => "auto-generated"
17     body :url => url_for(:host => SERVER_URL,
18                          :controller => "user", :action => "reset_password",
19                          :email => user.email, :token => token.token)
20   end
21
22   def reset_password(user, pass)
23     recipients user.email
24     from "webmaster@openstreetmap.org"
25     subject "[OpenStreetMap] Password reset"
26     headers "Auto-Submitted" => "auto-generated"
27     body :pass => pass
28   end
29
30   def gpx_success(trace, possible_points)
31     recipients trace.user.email
32     from "webmaster@openstreetmap.org"
33     subject "[OpenStreetMap] GPX Import success"
34     headers "Auto-Submitted" => "auto-generated"
35     body :trace_name => trace.name,
36          :trace_points => trace.size,
37          :possible_points => possible_points
38   end
39
40   def gpx_failure(trace, error)
41     recipients trace.user.email
42     from "webmaster@openstreetmap.org"
43     subject "[OpenStreetMap] GPX Import failure"
44     headers "Auto-Submitted" => "auto-generated"
45     body :trace_name => trace.name,
46          :error => error
47   end
48   
49   def message_notification(message)
50     recipients message.recipient.email
51     from "webmaster@openstreetmap.org"
52     subject "[OpenStreetMap] #{message.sender.display_name} sent you a new message"
53     headers "Auto-Submitted" => "auto-generated"
54     body :to_user => message.recipient.display_name,
55          :from_user => message.sender.display_name,
56          :body => message.body,
57          :subject => message.title,
58          :readurl => url_for(:host => SERVER_URL,
59                              :controller => "message", :action => "read",
60                              :message_id => message.id),
61          :replyurl => url_for(:host => SERVER_URL,
62                               :controller => "message", :action => "new",
63                               :user_id => message.from_user_id)
64   end
65
66   def friend_notification(friend)
67     befriender = User.find_by_id(friend.user_id)
68     befriendee = User.find_by_id(friend.friend_user_id)
69
70     recipients befriendee.email
71     from "webmaster@openstreetmap.org"
72     subject "[OpenStreetMap] #{befriender.display_name} added you as a friend"
73     headers "Auto-Submitted" => "auto-generated"
74     body :user => befriender.display_name,
75          :userurl => url_for(:host => SERVER_URL,
76                              :controller => "user", :action => "view",
77                              :display_name => befriender.display_name)
78   end
79 end