]> git.openstreetmap.org Git - rails.git/blob - app/models/notifier.rb
preference stuff
[rails.git] / app / models / notifier.rb
1
2 class Notifier < ActionMailer::Base
3   def signup_confirm(user, token)
4     recipients user.email
5     from "webmaster@openstreetmap.org"
6     subject "[OpenStreetMap] Confirm your email address"
7     headers "Auto-Submitted" => "auto-generated"
8     body :url => url_for(:host => SERVER_URL,
9                          :controller => "user", :action => "confirm",
10                          :confirm_string => token.token)
11   end
12
13   def lost_password(user, token)
14     recipients user.email
15     from "webmaster@openstreetmap.org"
16     subject "[OpenStreetMap] Password reset request"
17     headers "Auto-Submitted" => "auto-generated"
18     body :url => url_for(:host => SERVER_URL,
19                          :controller => "user", :action => "reset_password",
20                          :email => user.email, :token => token.token)
21   end
22
23   def reset_password(user, pass)
24     recipients user.email
25     from "webmaster@openstreetmap.org"
26     subject "[OpenStreetMap] Password reset"
27     headers "Auto-Submitted" => "auto-generated"
28     body :pass => pass
29   end
30
31   def gpx_success(trace, possible_points)
32     recipients trace.user.email
33     from "webmaster@openstreetmap.org"
34     subject "[OpenStreetMap] GPX Import success"
35     headers "Auto-Submitted" => "auto-generated"
36     body :trace_name => trace.name,
37          :trace_points => trace.size,
38          :possible_points => possible_points
39   end
40
41   def gpx_failure(trace, error)
42     recipients trace.user.email
43     from "webmaster@openstreetmap.org"
44     subject "[OpenStreetMap] GPX Import failure"
45     headers "Auto-Submitted" => "auto-generated"
46     body :trace_name => trace.name,
47          :error => error
48   end
49   
50   def message_notification(message)
51     recipients message.recipient.email
52     from "webmaster@openstreetmap.org"
53     subject "[OpenStreetMap] #{message.sender.display_name} sent you a new message"
54     headers "Auto-Submitted" => "auto-generated"
55     body :to_user => message.recipient.display_name,
56          :from_user => message.sender.display_name,
57          :body => message.body,
58          :subject => message.title,
59          :readurl => url_for(:host => SERVER_URL,
60                              :controller => "message", :action => "read",
61                              :message_id => message.id),
62          :replyurl => url_for(:host => SERVER_URL,
63                               :controller => "message", :action => "reply",
64                               :message_id => message.id)
65   end
66
67   def diary_comment_notification(comment)
68     recipients comment.diary_entry.user.email
69     from "webmaster@openstreetmap.org"
70     subject "[OpenStreetMap] #{comment.user.display_name} commented on your diary entry"
71     headers "Auto-Submitted" => "auto-generated"
72     body :to_user => comment.diary_entry.user.display_name,
73          :from_user => comment.user.display_name,
74          :body => comment.body,
75          :subject => comment.diary_entry.title,
76          :readurl => url_for(:host => SERVER_URL,
77                              :controller => "diary_entry",
78                              :action => "view",
79                              :display_name => comment.diary_entry.user.display_name,
80                              :id => comment.diary_entry.id,
81                              :anchor => "comment#{comment.id}"),
82          :commenturl => url_for(:host => SERVER_URL,
83                                 :controller => "diary_entry",
84                                 :action => "view",
85                                 :display_name => comment.diary_entry.user.display_name,
86                                 :id => comment.diary_entry.id,
87                                 :anchor => "newcomment"),
88          :replyurl => url_for(:host => SERVER_URL,
89                               :controller => "message",
90                               :action => "new",
91                               :user_id => comment.user.id,
92                               :title => "Re: #{comment.diary_entry.title}")
93   end
94
95   def friend_notification(friend)
96     befriender = User.find_by_id(friend.user_id)
97     befriendee = User.find_by_id(friend.friend_user_id)
98
99     recipients befriendee.email
100     from "webmaster@openstreetmap.org"
101     subject "[OpenStreetMap] #{befriender.display_name} added you as a friend"
102     headers "Auto-Submitted" => "auto-generated"
103     body :user => befriender.display_name,
104          :userurl => url_for(:host => SERVER_URL,
105                              :controller => "user", :action => "view",
106                              :display_name => befriender.display_name)
107   end
108 end