@@ -1,105 +1,107 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2008 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2008 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | namespace :redmine do |
|
18 | namespace :redmine do | |
19 | namespace :email do |
|
19 | namespace :email do | |
20 |
|
20 | |||
21 | desc <<-END_DESC |
|
21 | desc <<-END_DESC | |
22 | Read an email from standard input. |
|
22 | Read an email from standard input. | |
23 |
|
23 | |||
24 | Issue attributes control options: |
|
24 | Issue attributes control options: | |
25 | project=PROJECT identifier of the target project |
|
25 | project=PROJECT identifier of the target project | |
|
26 | status=STATUS name of the target status | |||
26 | tracker=TRACKER name of the target tracker |
|
27 | tracker=TRACKER name of the target tracker | |
27 | category=CATEGORY name of the target category |
|
28 | category=CATEGORY name of the target category | |
28 | priority=PRIORITY name of the target priority |
|
29 | priority=PRIORITY name of the target priority | |
29 | allow_override=ATTRS allow email content to override attributes |
|
30 | allow_override=ATTRS allow email content to override attributes | |
30 | specified by previous options |
|
31 | specified by previous options | |
31 | ATTRS is a comma separated list of attributes |
|
32 | ATTRS is a comma separated list of attributes | |
32 |
|
33 | |||
33 | Examples: |
|
34 | Examples: | |
34 | # No project specified. Emails MUST contain the 'Project' keyword: |
|
35 | # No project specified. Emails MUST contain the 'Project' keyword: | |
35 | rake redmine:email:read RAILS_ENV="production" < raw_email |
|
36 | rake redmine:email:read RAILS_ENV="production" < raw_email | |
36 |
|
37 | |||
37 | # Fixed project and default tracker specified, but emails can override |
|
38 | # Fixed project and default tracker specified, but emails can override | |
38 | # both tracker and priority attributes: |
|
39 | # both tracker and priority attributes: | |
39 | rake redmine:email:read RAILS_ENV="production" \\ |
|
40 | rake redmine:email:read RAILS_ENV="production" \\ | |
40 | project=foo \\ |
|
41 | project=foo \\ | |
41 | tracker=bug \\ |
|
42 | tracker=bug \\ | |
42 | allow_override=tracker,priority < raw_email |
|
43 | allow_override=tracker,priority < raw_email | |
43 | END_DESC |
|
44 | END_DESC | |
44 |
|
45 | |||
45 | task :read => :environment do |
|
46 | task :read => :environment do | |
46 | options = { :issue => {} } |
|
47 | options = { :issue => {} } | |
47 | %w(project tracker category priority).each { |a| options[:issue][a.to_sym] = ENV[a] if ENV[a] } |
|
48 | %w(project status tracker category priority).each { |a| options[:issue][a.to_sym] = ENV[a] if ENV[a] } | |
48 | options[:allow_override] = ENV['allow_override'] if ENV['allow_override'] |
|
49 | options[:allow_override] = ENV['allow_override'] if ENV['allow_override'] | |
49 |
|
50 | |||
50 | MailHandler.receive(STDIN.read, options) |
|
51 | MailHandler.receive(STDIN.read, options) | |
51 | end |
|
52 | end | |
52 |
|
53 | |||
53 | desc <<-END_DESC |
|
54 | desc <<-END_DESC | |
54 | Read emails from an IMAP server. |
|
55 | Read emails from an IMAP server. | |
55 |
|
56 | |||
56 | Available IMAP options: |
|
57 | Available IMAP options: | |
57 | host=HOST IMAP server host (default: 127.0.0.1) |
|
58 | host=HOST IMAP server host (default: 127.0.0.1) | |
58 | port=PORT IMAP server port (default: 143) |
|
59 | port=PORT IMAP server port (default: 143) | |
59 | ssl=SSL Use SSL? (default: false) |
|
60 | ssl=SSL Use SSL? (default: false) | |
60 | username=USERNAME IMAP account |
|
61 | username=USERNAME IMAP account | |
61 | password=PASSWORD IMAP password |
|
62 | password=PASSWORD IMAP password | |
62 | folder=FOLDER IMAP folder to read (default: INBOX) |
|
63 | folder=FOLDER IMAP folder to read (default: INBOX) | |
63 |
|
64 | |||
64 | Issue attributes control options: |
|
65 | Issue attributes control options: | |
65 | project=PROJECT identifier of the target project |
|
66 | project=PROJECT identifier of the target project | |
|
67 | status=STATUS name of the target status | |||
66 | tracker=TRACKER name of the target tracker |
|
68 | tracker=TRACKER name of the target tracker | |
67 | category=CATEGORY name of the target category |
|
69 | category=CATEGORY name of the target category | |
68 | priority=PRIORITY name of the target priority |
|
70 | priority=PRIORITY name of the target priority | |
69 | allow_override=ATTRS allow email content to override attributes |
|
71 | allow_override=ATTRS allow email content to override attributes | |
70 | specified by previous options |
|
72 | specified by previous options | |
71 | ATTRS is a comma separated list of attributes |
|
73 | ATTRS is a comma separated list of attributes | |
72 |
|
74 | |||
73 | Examples: |
|
75 | Examples: | |
74 | # No project specified. Emails MUST contain the 'Project' keyword: |
|
76 | # No project specified. Emails MUST contain the 'Project' keyword: | |
75 |
|
77 | |||
76 | rake redmine:email:receive_iamp RAILS_ENV="production" \\ |
|
78 | rake redmine:email:receive_iamp RAILS_ENV="production" \\ | |
77 | host=imap.foo.bar username=redmine@example.net password=xxx |
|
79 | host=imap.foo.bar username=redmine@example.net password=xxx | |
78 |
|
80 | |||
79 |
|
81 | |||
80 | # Fixed project and default tracker specified, but emails can override |
|
82 | # Fixed project and default tracker specified, but emails can override | |
81 | # both tracker and priority attributes: |
|
83 | # both tracker and priority attributes: | |
82 |
|
84 | |||
83 | rake redmine:email:receive_iamp RAILS_ENV="production" \\ |
|
85 | rake redmine:email:receive_iamp RAILS_ENV="production" \\ | |
84 | host=imap.foo.bar username=redmine@example.net password=xxx ssl=1 \\ |
|
86 | host=imap.foo.bar username=redmine@example.net password=xxx ssl=1 \\ | |
85 | project=foo \\ |
|
87 | project=foo \\ | |
86 | tracker=bug \\ |
|
88 | tracker=bug \\ | |
87 | allow_override=tracker,priority |
|
89 | allow_override=tracker,priority | |
88 | END_DESC |
|
90 | END_DESC | |
89 |
|
91 | |||
90 | task :receive_imap => :environment do |
|
92 | task :receive_imap => :environment do | |
91 | imap_options = {:host => ENV['host'], |
|
93 | imap_options = {:host => ENV['host'], | |
92 | :port => ENV['port'], |
|
94 | :port => ENV['port'], | |
93 | :ssl => ENV['ssl'], |
|
95 | :ssl => ENV['ssl'], | |
94 | :username => ENV['username'], |
|
96 | :username => ENV['username'], | |
95 | :password => ENV['password'], |
|
97 | :password => ENV['password'], | |
96 | :folder => ENV['folder']} |
|
98 | :folder => ENV['folder']} | |
97 |
|
99 | |||
98 | options = { :issue => {} } |
|
100 | options = { :issue => {} } | |
99 | %w(project tracker category priority).each { |a| options[:issue][a.to_sym] = ENV[a] if ENV[a] } |
|
101 | %w(project status tracker category priority).each { |a| options[:issue][a.to_sym] = ENV[a] if ENV[a] } | |
100 | options[:allow_override] = ENV['allow_override'] if ENV['allow_override'] |
|
102 | options[:allow_override] = ENV['allow_override'] if ENV['allow_override'] | |
101 |
|
103 | |||
102 | Redmine::IMAP.check(imap_options, options) |
|
104 | Redmine::IMAP.check(imap_options, options) | |
103 | end |
|
105 | end | |
104 | end |
|
106 | end | |
105 | end |
|
107 | end |
General Comments 0
You need to be logged in to leave comments.
Login now