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