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