]> git.openstreetmap.org Git - rails.git/blob - app/models/notifier.rb
Revert Potlatch 0.10 from the trunk - we will keep it on the potlatch_010
[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          :trace_description => trace.description,
39          :trace_tags => trace.tags,
40          :possible_points => possible_points
41   end
42
43   def gpx_failure(trace, error)
44     recipients trace.user.email
45     from "webmaster@openstreetmap.org"
46     subject "[OpenStreetMap] GPX Import failure"
47     headers "Auto-Submitted" => "auto-generated"
48     body :trace_name => trace.name,
49          :trace_description => trace.description,
50          :trace_tags => trace.tags,
51          :error => error
52   end
53   
54   def message_notification(message)
55     recipients message.recipient.email
56     from "webmaster@openstreetmap.org"
57     subject "[OpenStreetMap] #{message.sender.display_name} sent you a new message"
58     headers "Auto-Submitted" => "auto-generated"
59     body :to_user => message.recipient.display_name,
60          :from_user => message.sender.display_name,
61          :body => message.body,
62          :subject => message.title,
63          :readurl => url_for(:host => SERVER_URL,
64                              :controller => "message", :action => "read",
65                              :message_id => message.id),
66          :replyurl => url_for(:host => SERVER_URL,
67                               :controller => "message", :action => "reply",
68                               :message_id => message.id)
69   end
70
71   def diary_comment_notification(comment)
72     recipients comment.diary_entry.user.email
73     from "webmaster@openstreetmap.org"
74     subject "[OpenStreetMap] #{comment.user.display_name} commented on your diary entry"
75     headers "Auto-Submitted" => "auto-generated"
76     body :to_user => comment.diary_entry.user.display_name,
77          :from_user => comment.user.display_name,
78          :body => comment.body,
79          :subject => comment.diary_entry.title,
80          :readurl => url_for(:host => SERVER_URL,
81                              :controller => "diary_entry",
82                              :action => "view",
83                              :display_name => comment.diary_entry.user.display_name,
84                              :id => comment.diary_entry.id,
85                              :anchor => "comment#{comment.id}"),
86          :commenturl => url_for(:host => SERVER_URL,
87                                 :controller => "diary_entry",
88                                 :action => "view",
89                                 :display_name => comment.diary_entry.user.display_name,
90                                 :id => comment.diary_entry.id,
91                                 :anchor => "newcomment"),
92          :replyurl => url_for(:host => SERVER_URL,
93                               :controller => "message",
94                               :action => "new",
95                               :user_id => comment.user.id,
96                               :title => "Re: #{comment.diary_entry.title}")
97   end
98
99   def friend_notification(friend)
100     befriender = User.find_by_id(friend.user_id)
101     befriendee = User.find_by_id(friend.friend_user_id)
102
103     recipients befriendee.email
104     from "webmaster@openstreetmap.org"
105     subject "[OpenStreetMap] #{befriender.display_name} added you as a friend"
106     headers "Auto-Submitted" => "auto-generated"
107     body :user => befriender.display_name,
108          :userurl => url_for(:host => SERVER_URL,
109                              :controller => "user", :action => "view",
110                              :display_name => befriender.display_name)
111   end
112 end