##// END OF EJS Templates
Added a simple mail handler....
Jean-Philippe Lang -
r520:42193960f2f4
parent child
Show More
@@ -0,0 +1,40
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
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
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 class MailHandler < ActionMailer::Base
19
20 # Processes incoming emails
21 # Currently, it only supports adding notes to an existing issue
22 # by replying to the initial notification message
23 def receive(email)
24 # find related issue by parsing the subject
25 m = email.subject.match %r{\[.*#(\d+)\]}
26 return unless m
27 issue = Issue.find_by_id(m[1])
28 return unless issue
29
30 # find user
31 user = User.find_active(:first, :conditions => {:mail => email.from.first})
32 return unless user
33 # check permission
34 return unless Permission.allowed_to_role("issues/add_note", user.role_for_project(issue.project))
35
36 # add the notes
37 issue.init_journal(user, email.body)
38 issue.save
39 end
40 end
General Comments 0
You need to be logged in to leave comments. Login now