Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 10
- Log:
Checking in HEAD from RForum's SVN of 22-Jul-2006, 8pm (revision 906).
- Author:
- adh
- Date:
- Sat Jul 22 20:02:44 +0100 2006
- Size:
- 3620 Bytes
1 | require 'url_generator' |
2 | require 'digest/md5' |
3 | require 'received_mail' |
4 | |
5 | class Mailer < ActionMailer::Base |
6 | |
7 | include RForum::Localization |
8 | |
9 | def registration_mail(user, password, login_url) |
10 | setup_email(user) |
11 | @subject += l(:welcome_to, RForum::CONFIG[:site_name]) |
12 | @body = { 'user' => user, 'password' => password, 'login_url' => login_url } |
13 | end |
14 | |
15 | def new_post_notification(user, post) |
16 | setup_email(user) |
17 | # TODO: how to get topic URL from here? |
18 | # TODO: take care of non-ASCII chars in subject |
19 | @subject += l(:new_post_in_thread, post.topic.subject) |
20 | @body['post_url'] = UrlGenerator.url_for(:controller => 'topic', :action => 'show', :id => post.topic_id, :anchor => post.id) |
21 | @body['disable_notification_url'] = UrlGenerator.url_for(:controller => 'topic', :action => 'unsubscribe', :id => post.topic_id) |
22 | @body['post'] = post |
23 | @body['user'] = user |
24 | end |
25 | |
26 | def reset_password(user, reset_password_url) |
27 | setup_email(user) |
28 | @subject += l(:reset_password_subject) |
29 | @body['user'] = user |
30 | @body['reset_password_url'] = reset_password_url |
31 | end |
32 | |
33 | def user_message(from, to, text) |
34 | setup_email(to) |
35 | @from = from.email |
36 | @subject += l(:user_message_from, from.name) |
37 | @body['text'] = Wraptools.wrap_ff(text, 72) |
38 | @body['from'] = from |
39 | @body['to'] = to |
40 | end |
41 | |
42 | def delete_post_notification(post) |
43 | setup_email(post.author) |
44 | @body['post'] = post |
45 | end |
46 | |
47 | def ml_post(post) |
48 | unless post.topic.forum.list_address |
49 | raise RuntimeError |
50 | end |
51 | |
52 | footer = "\n\n-- \nPosted via http://www.ruby-forum.com/." |
53 | @body = post.text + footer |
54 | |
55 | |
56 | if post.author.guest? |
57 | name = (post.author.guest_name || 'Guest').dup |
58 | email = post.author.guest_email |
59 | else |
60 | name = "#{post.author.firstname} #{post.author.surname}" |
61 | email = post.author.email |
62 | end |
63 | |
64 | if post.topic.forum.ml_from_address |
65 | email = post.topic.forum.ml_from_address |
66 | end |
67 | |
68 | @from = "#{name} <#{email}>" |
69 | |
70 | @subject = post.subject |
71 | @recipients = post.topic.forum.list_address |
72 | @sent_on = post.created_at |
73 | |
74 | @headers['Content-Type'] = "text/plain; charset=#{RForum::CONFIG[:mail_charset]}; format=flowed" |
75 | @headers['reply-to'] = post.topic.forum.list_address |
76 | #@headers["bcc"] = (users.collect { |u| u.email }).join "," |
77 | @headers['sender'] = @headers['errors-to'] = RForum::CONFIG[:bounce_address] |
78 | @headers['message-id'] = '<' + post.messageid + '>' |
79 | |
80 | if post.parent |
81 | @headers['in-reply-to'] = '<' + post.parent.messageid + '>' |
82 | @headers['references'] = post.get_references |
83 | end |
84 | |
85 | if headers = post.topic.forum.add_mail_headers |
86 | headers.each_line do |line| |
87 | key, value = line.split(/\s*:\s*/, 2) |
88 | @headers[key] = value |
89 | end |
90 | end |
91 | end |
92 | |
93 | def receive(email) |
94 | email.extend(ReceivedMail) |
95 | |
96 | end |
97 | |
98 | def self.process_email(raw) |
99 | email = self.receive(raw) |
100 | unless RForum::CONFIG[:accept_mail_from_guests] |
101 | if email.from_guest? |
102 | # TODO: bounce |
103 | raise 'email from guest' |
104 | end |
105 | |
106 | if email.from_unauthorized_user? |
107 | # TODO: bounce |
108 | raise 'email from unauthorized user' |
109 | end |
110 | end |
111 | |
112 | email.create_post |
113 | end |
114 | |
115 | protected |
116 | |
117 | def setup_email(user) |
118 | @recipients = user.email |
119 | @subject = "[#{RForum::CONFIG[:site_name]}] " |
120 | @from = RForum::CONFIG[:site_email] |
121 | @headers['Content-Type'] = "text/plain; charset=#{RForum::CONFIG[:mail_charset]}; format=flowed" |
122 | end |
123 | |
124 | def template_path |
125 | template_root + "/" + Inflector.underscore(self.class.name) + "/" + RForum::CONFIG[:default_language] |
126 | end |
127 | |
128 | end |