]> git.openstreetmap.org Git - rails.git/blob - app/models/notifier.rb
Tidy up mail notifiers and make them more rails style rather then
[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     body :url => url_for(:host => SERVER_URL,
7                          :controller => "user", :action => "confirm",
8                          :confirm_string => token.token)
9   end
10
11   def lost_password(user, token)
12     recipients user.email
13     from "webmaster@openstreetmap.org"
14     subject "[OpenStreetMap] Password reset request"
15     body :url => url_for(:host => SERVER_URL,
16                          :controller => "user", :action => "reset_password",
17                          :email => user.email, :token => token.token)
18   end
19
20   def reset_password(user, pass)
21     recipients user.email
22     from "webmaster@openstreetmap.org"
23     subject "[OpenStreetMap] Password reset"
24     body :pass => pass
25   end
26
27   def gpx_success(trace, possible_points)
28     recipients trace.user.email
29     from "webmaster@openstreetmap.org"
30     subject "[OpenStreetMap] GPX Import success"
31     body :trace_name => trace.name,
32          :trace_points => trace.size,
33          :possible_points => possible_points
34   end
35
36   def gpx_failure(trace, error)
37     recipients trace.user.email
38     from "webmaster@openstreetmap.org"
39     subject "[OpenStreetMap] GPX Import failure"
40     body :trace_name => trace.name,
41          :error => error
42   end
43   
44   def message_notification(message)
45     recipients message.recipient.email
46     from "webmaster@openstreetmap.org"
47     subject "[OpenStreetMap] #{message.sender.display_name} sent you a new message"
48     body :to_user => message.recipient.display_name,
49          :from_user => message.sender.display_name,
50          :body => message.body,
51          :subject => message.title,
52          :readurl => url_for(:host => SERVER_URL,
53                              :controller => "message", :action => "read",
54                              :message_id => message.id),
55          :replyurl => url_for(:host => SERVER_URL,
56                               :controller => "message", :action => "new",
57                               :user_id => message.from_user_id)
58   end
59
60   def friend_notification(friend)
61     befriender = User.find_by_id(friend.user_id)
62     befriendee = User.find_by_id(friend.friend_user_id)
63
64     recipients befriendee.email
65     from "webmaster@openstreetmap.org"
66     subject "[OpenStreetMap] #{befriender.display_name} added you as a friend"
67     body :user => befriender.display_name,
68          :userurl => url_for(:host => SERVER_URL,
69                              :controller => "user", :action => "view",
70                              :display_name => befriender.display_name)
71   end
72 end