Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 7
- Log:
Initial import of RForum 0.2 sources from a downloaded Tarball.
RForum is a Ruby On Rails based forum and mail gateway service.
- Author:
- adh
- Date:
- Sat Jul 22 18:43:13 +0100 2006
- Size:
- 1830 Bytes
- Properties:
- Property svn:executable is set
1 | #!/usr/bin/env ruby |
2 | |
3 | unless maildir = ARGV[0] |
4 | puts 'Usage: script/process_mails directory [time between checks in minutes]' |
5 | puts 'Example: script/process_mails Maildir/.Rails/new 5' |
6 | exit |
7 | end |
8 | |
9 | sleeptime = ARGV[1].to_i |
10 | |
11 | require File.dirname(__FILE__) + '/../config/environment' |
12 | require 'fileutils' |
13 | require 'breakpoint' |
14 | |
15 | def do_import(maildir) |
16 | puts "Checking for new mails" |
17 | Dir[File.join(maildir, '*')].each do |file| |
18 | begin |
19 | if Mailer.process_email(File.read(file)) |
20 | puts "Imported #{file}" |
21 | File.delete(file) |
22 | else |
23 | puts "Could not import #{file}" |
24 | end |
25 | rescue => e |
26 | if e.is_a? Iconv::InvalidEncoding |
27 | puts "Skipped file #{file} (invalid encoding)" |
28 | FileUtils.move(file, RAILS_ROOT + '/mails/rejected/invalid_encoding/') rescue ArgumentError |
29 | elsif e.message['messageid : has already been taken'] |
30 | puts "Skipped file #{file} (messageid already in database)" |
31 | FileUtils.move(file, RAILS_ROOT + '/mails/rejected/messageid_duplicate/') rescue ArgumentError |
32 | elsif e.is_a? RForum::ValidationError |
33 | puts "Skipped file #{file} (ValidationError): #{e.inspect}" |
34 | FileUtils.move(file, RAILS_ROOT + '/mails/rejected/validation_error/') rescue ArgumentError |
35 | elsif e.message['parent not found'] |
36 | puts "Skipped file #{file} (parent not found): #{e.inspect}" |
37 | FileUtils.move(file, RAILS_ROOT + '/mails/rejected/parent_not_found/') rescue ArgumentError |
38 | else |
39 | puts "Skipped file #{file} (unknown error): #{e.inspect}" |
40 | FileUtils.move(file, RAILS_ROOT + '/mails/rejected/unknown_error/') rescue ArgumentError |
41 | end |
42 | end |
43 | end |
44 | end |
45 | |
46 | if sleeptime == 0 |
47 | do_import(maildir) |
48 | else |
49 | loop do |
50 | do_import(maildir) |
51 | GC.start |
52 | puts "sleeping for #{sleeptime} minutes..." |
53 | sleep sleeptime * 60 |
54 | end |
55 | end |