]> source.dussan.org Git - redmine.git/commitdiff
Adds basic support for issue creation via email (#1110).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 22 Jun 2008 10:45:03 +0000 (10:45 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 22 Jun 2008 10:45:03 +0000 (10:45 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1568 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/mail_handler.rb
lib/tasks/email.rake [new file with mode: 0644]
test/fixtures/enabled_modules.yml
test/fixtures/enumerations.yml
test/fixtures/mail_handler/add_note_to_issue.txt [deleted file]
test/fixtures/mail_handler/ticket_on_given_project.eml [new file with mode: 0644]
test/fixtures/mail_handler/ticket_reply.eml [new file with mode: 0644]
test/fixtures/mail_handler/ticket_with_attachment.eml [new file with mode: 0644]
test/unit/mail_handler_test.rb

index 7a1d7324472fb7d648306a990927f41cc073cccc..03e48e170b780d77c324d36c8376a1e0dcf186e1 100644 (file)
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 class MailHandler < ActionMailer::Base
+
+  class UnauthorizedAction < StandardError; end
+  class MissingInformation < StandardError; end
+  
+  attr_reader :email, :user
+
+  def self.receive(email, options={})
+    @@handler_options = options
+    super email
+  end
   
   # Processes incoming emails
-  # Currently, it only supports adding a note to an existing issue
-  # by replying to the initial notification message
   def receive(email)
-    # find related issue by parsing the subject
-    m = email.subject.match %r{\[.*#(\d+)\]}
-    return unless m
-    issue = Issue.find_by_id(m[1])
+    @email = email
+    @user = User.find_active(:first, :conditions => {:mail => email.from.first})
+    unless @user
+      # Unknown user => the email is ignored
+      # TODO: ability to create the user's account
+      logger.info "MailHandler: email submitted by unknown user [#{email.from.first}]" if logger && logger.info
+      return false
+    end
+    User.current = @user
+    dispatch
+  end
+  
+  private
+
+  ISSUE_REPLY_SUBJECT_RE = %r{\[[^\]]+#(\d+)\]}
+  
+  def dispatch
+    if m = email.subject.match(ISSUE_REPLY_SUBJECT_RE)
+      receive_issue_update(m[1].to_i)
+    else
+      receive_issue
+    end
+  rescue ActiveRecord::RecordInvalid => e
+    # TODO: send a email to the user
+    logger.error e.message if logger
+    false
+  rescue MissingInformation => e
+    logger.error "MailHandler: missing information from #{user}: #{e.message}" if logger
+    false
+  rescue UnauthorizedAction => e
+    logger.error "MailHandler: unauthorized attempt from #{user}" if logger
+    false
+  end
+  
+  # Creates a new issue
+  def receive_issue
+    project = target_project
+    # TODO: make the tracker configurable
+    tracker = project.trackers.find(:first)
+    # check permission
+    raise UnauthorizedAction unless user.allowed_to?(:add_issues, project)
+    issue = Issue.new(:author => user, :project => project, :tracker => tracker)
+    issue.subject = email.subject.chomp
+    issue.description = email.plain_text_body.chomp
+    issue.save!
+    add_attachments(issue)
+    logger.info "MailHandler: issue ##{issue.id} created by #{user}" if logger && logger.info
+    Mailer.deliver_issue_add(issue) if Setting.notified_events.include?('issue_added')
+    issue
+  end
+  
+  def target_project
+    # TODO: other ways to specify project:
+    # * parse the email To field
+    # * specific project (eg. Setting.mail_handler_target_project)
+    identifier = if @@handler_options[:project]
+                   @@handler_options[:project]
+                 elsif email.plain_text_body =~ %r{^Project:[ \t]*(.+)$}i
+                    $1
+                 end
+                 
+    target = Project.find_by_identifier(identifier.to_s)
+    raise MissingInformation.new('Unable to determine target project') if target.nil?
+    target
+  end
+  
+  # Adds a note to an existing issue
+  def receive_issue_update(issue_id)
+    issue = Issue.find_by_id(issue_id)
     return unless issue
-    
-    # find user
-    user = User.find_active(:first, :conditions => {:mail => email.from.first})
-    return unless user
     # check permission
-    return unless user.allowed_to?(:add_issue_notes, issue.project)
-    
+    raise UnauthorizedAction unless user.allowed_to?(:add_issue_notes, issue.project) || user.allowed_to?(:edit_issues, issue.project)
     # add the note
-    issue.init_journal(user, email.body.chomp)
-    issue.save
+    journal = issue.init_journal(user, email.plain_text_body.chomp)
+    add_attachments(journal)
+    issue.save!
+    logger.info "MailHandler: issue ##{issue.id} updated by #{user}" if logger && logger.info
+    Mailer.deliver_issue_edit(journal) if Setting.notified_events.include?('issue_updated')
+    journal
+  end
+  
+  def add_attachments(obj)
+    if email.has_attachments?
+      email.attachments.each do |attachment|
+        Attachment.create(:container => obj,
+                          :file => attachment,
+                          :author => user,
+                          :content_type => attachment.content_type)
+      end
+    end
   end
 end
+
+class TMail::Mail
+  # Returns body of the first plain text part found if any
+  def plain_text_body
+    return @plain_text_body unless @plain_text_body.nil?
+    p = self.parts.collect {|c| (c.respond_to?(:parts) && !c.parts.empty?) ? c.parts : c}.flatten
+    plain = p.detect {|c| c.content_type == 'text/plain'}
+    @plain_text_body = plain.nil? ? self.body : plain.body
+  end
+end
+
diff --git a/lib/tasks/email.rake b/lib/tasks/email.rake
new file mode 100644 (file)
index 0000000..dbdbe71
--- /dev/null
@@ -0,0 +1,37 @@
+# redMine - project management software\r
+# Copyright (C) 2006-2008  Jean-Philippe Lang\r
+#\r
+# This program is free software; you can redistribute it and/or\r
+# modify it under the terms of the GNU General Public License\r
+# as published by the Free Software Foundation; either version 2\r
+# of the License, or (at your option) any later version.\r
+# \r
+# This program is distributed in the hope that it will be useful,\r
+# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+# GNU General Public License for more details.\r
+# \r
+# You should have received a copy of the GNU General Public License\r
+# along with this program; if not, write to the Free Software\r
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\r
+\r
+desc <<-END_DESC\r
+Read an email from standard input.\r
+\r
+Available options:\r
+  * project => identifier of the project the issue should be added to\r
+  \r
+Example:\r
+  rake redmine:email:receive project=foo RAILS_ENV="production"\r
+END_DESC\r
+\r
+namespace :redmine do\r
+  namespace :email do\r
+    task :receive => :environment do\r
+      options = {}\r
+      options[:project] = ENV['project'] if ENV['project']\r
+      \r
+      MailHandler.receive(STDIN.read, options)\r
+    end\r
+  end\r
+end\r
index 8d1565534d0e6f832232f5d886024fa77cef1fa9..da63bad5d93ceccb4f294fd60bb1642a21b24776 100644 (file)
@@ -39,4 +39,8 @@ enabled_modules_010:
   name: wiki
   project_id: 3
   id: 10
+enabled_modules_011: 
+  name: issue_tracking
+  project_id: 2
+  id: 11
   
\ No newline at end of file
index 5e2615476970ca1b14a36b7c5d51313b6249b8ea..22a581ab90f7f44a8b976ee3f100ea99a013c94e 100644 (file)
@@ -19,6 +19,7 @@ enumerations_005:
   name: Normal\r
   id: 5\r
   opt: IPRI\r
+  is_default: true\r
 enumerations_006: \r
   name: High\r
   id: 6\r
diff --git a/test/fixtures/mail_handler/add_note_to_issue.txt b/test/fixtures/mail_handler/add_note_to_issue.txt
deleted file mode 100644 (file)
index 4fc6b68..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-x-sender: <jsmith@somenet.foo>\r
-x-receiver: <redmine@somenet.foo>\r
-Received: from somenet.foo ([127.0.0.1]) by somenet.foo;\r
-       Sun, 25 Feb 2007 09:57:56 GMT\r
-Date: Sun, 25 Feb 2007 10:57:56 +0100\r
-From: jsmith@somenet.foo\r
-To: redmine@somenet.foo\r
-Message-Id: <45e15df440c00_b90238570a27b@osiris.tmail>\r
-In-Reply-To: <45e15df440c29_b90238570a27b@osiris.tmail>\r
-Subject: [Cookbook - Feature #2]\r
-Mime-Version: 1.0\r
-Content-Type: text/plain; charset=utf-8\r
-\r
-Note added by mail\r
diff --git a/test/fixtures/mail_handler/ticket_on_given_project.eml b/test/fixtures/mail_handler/ticket_on_given_project.eml
new file mode 100644 (file)
index 0000000..07c7f16
--- /dev/null
@@ -0,0 +1,41 @@
+Return-Path: <jsmith@somenet.foo>\r
+Received: from osiris ([127.0.0.1])\r
+       by OSIRIS\r
+       with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200\r
+Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris>\r
+From: "John Smith" <jsmith@somenet.foo>\r
+To: <redmine@somenet.foo>\r
+Subject: New ticket on a given project\r
+Date: Sun, 22 Jun 2008 12:28:07 +0200\r
+MIME-Version: 1.0\r
+Content-Type: text/plain;\r
+       format=flowed;\r
+       charset="iso-8859-1";\r
+       reply-type=original\r
+Content-Transfer-Encoding: 7bit\r
+X-Priority: 3\r
+X-MSMail-Priority: Normal\r
+X-Mailer: Microsoft Outlook Express 6.00.2900.2869\r
+X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869\r
+\r
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas imperdiet \r
+turpis et odio. Integer eget pede vel dolor euismod varius. Phasellus \r
+blandit eleifend augue. Nulla facilisi. Duis id diam. Class aptent taciti \r
+sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In \r
+in urna sed tellus aliquet lobortis. Morbi scelerisque tortor in dolor. Cras \r
+sagittis odio eu lacus. Aliquam sem tortor, consequat sit amet, vestibulum \r
+id, iaculis at, lectus. Fusce tortor libero, congue ut, euismod nec, luctus \r
+eget, eros. Pellentesque tortor enim, feugiat in, dignissim eget, tristique \r
+sed, mauris. Pellentesque habitant morbi tristique senectus et netus et \r
+malesuada fames ac turpis egestas. Quisque sit amet libero. In hac habitasse \r
+platea dictumst.\r
+\r
+Nulla et nunc. Duis pede. Donec et ipsum. Nam ut dui tincidunt neque \r
+sollicitudin iaculis. Duis vitae dolor. Vestibulum eget massa. Sed lorem. \r
+Nullam volutpat cursus erat. Cras felis dolor, lacinia quis, rutrum et, \r
+dictum et, ligula. Sed erat nibh, gravida in, accumsan non, placerat sed, \r
+massa. Sed sodales, ante fermentum ultricies sollicitudin, massa leo \r
+pulvinar dui, a gravida orci mi eget odio. Nunc a lacus.\r
+\r
+Project: onlinestore\r
+\r
diff --git a/test/fixtures/mail_handler/ticket_reply.eml b/test/fixtures/mail_handler/ticket_reply.eml
new file mode 100644 (file)
index 0000000..99fcfa0
--- /dev/null
@@ -0,0 +1,73 @@
+Return-Path: <jsmith@somenet.foo>\r
+Received: from osiris ([127.0.0.1])\r
+       by OSIRIS\r
+       with hMailServer ; Sat, 21 Jun 2008 18:41:39 +0200\r
+Message-ID: <006a01c8d3bd$ad9baec0$0a00a8c0@osiris>\r
+From: "John Smith" <jsmith@somenet.foo>\r
+To: <redmine@somenet.foo>\r
+References: <485d0ad366c88_d7014663a025f@osiris.tmail>\r
+Subject: Re: [Cookbook - Feature #2] (New) Add ingredients categories\r
+Date: Sat, 21 Jun 2008 18:41:39 +0200\r
+MIME-Version: 1.0\r
+Content-Type: multipart/alternative;\r
+       boundary="----=_NextPart_000_0067_01C8D3CE.711F9CC0"\r
+X-Priority: 3\r
+X-MSMail-Priority: Normal\r
+X-Mailer: Microsoft Outlook Express 6.00.2900.2869\r
+X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869\r
+\r
+This is a multi-part message in MIME format.\r
+\r
+------=_NextPart_000_0067_01C8D3CE.711F9CC0\r
+Content-Type: text/plain;\r
+       charset="utf-8"\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+This is reply\r
+------=_NextPart_000_0067_01C8D3CE.711F9CC0\r
+Content-Type: text/html;\r
+       charset="utf-8"\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+=EF=BB=BF<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">\r
+<HTML><HEAD>\r
+<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dutf-8">\r
+<STYLE>BODY {\r
+       FONT-SIZE: 0.8em; COLOR: #484848; FONT-FAMILY: Verdana, sans-serif\r
+}\r
+BODY H1 {\r
+       FONT-SIZE: 1.2em; MARGIN: 0px; FONT-FAMILY: "Trebuchet MS", Verdana, =\r
+sans-serif\r
+}\r
+A {\r
+       COLOR: #2a5685\r
+}\r
+A:link {\r
+       COLOR: #2a5685\r
+}\r
+A:visited {\r
+       COLOR: #2a5685\r
+}\r
+A:hover {\r
+       COLOR: #c61a1a\r
+}\r
+A:active {\r
+       COLOR: #c61a1a\r
+}\r
+HR {\r
+       BORDER-RIGHT: 0px; BORDER-TOP: 0px; BACKGROUND: #ccc; BORDER-LEFT: 0px; =\r
+WIDTH: 100%; BORDER-BOTTOM: 0px; HEIGHT: 1px\r
+}\r
+.footer {\r
+       FONT-SIZE: 0.8em; FONT-STYLE: italic\r
+}\r
+</STYLE>\r
+\r
+<META content=3D"MSHTML 6.00.2900.2883" name=3DGENERATOR></HEAD>\r
+<BODY bgColor=3D#ffffff>\r
+<DIV><SPAN class=3Dfooter><FONT face=3DArial color=3D#000000 =\r
+size=3D2>This is=20\r
+reply</FONT></DIV></SPAN></BODY></HTML>\r
+\r
+------=_NextPart_000_0067_01C8D3CE.711F9CC0--\r
+\r
diff --git a/test/fixtures/mail_handler/ticket_with_attachment.eml b/test/fixtures/mail_handler/ticket_with_attachment.eml
new file mode 100644 (file)
index 0000000..c85f6b4
--- /dev/null
@@ -0,0 +1,248 @@
+Return-Path: <jsmith@somenet.foo>\r
+Received: from osiris ([127.0.0.1])\r
+       by OSIRIS\r
+       with hMailServer ; Sat, 21 Jun 2008 15:53:25 +0200\r
+Message-ID: <002301c8d3a6$2cdf6950$0a00a8c0@osiris>\r
+From: "John Smith" <jsmith@somenet.foo>\r
+To: <redmine@somenet.foo>\r
+Subject: Ticket created by email with attachment\r
+Date: Sat, 21 Jun 2008 15:53:25 +0200\r
+MIME-Version: 1.0\r
+Content-Type: multipart/mixed;\r
+       boundary="----=_NextPart_000_001F_01C8D3B6.F05C5270"\r
+X-Priority: 3\r
+X-MSMail-Priority: Normal\r
+X-Mailer: Microsoft Outlook Express 6.00.2900.2869\r
+X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869\r
+\r
+This is a multi-part message in MIME format.\r
+\r
+------=_NextPart_000_001F_01C8D3B6.F05C5270\r
+Content-Type: multipart/alternative;\r
+       boundary="----=_NextPart_001_0020_01C8D3B6.F05C5270"\r
+\r
+\r
+------=_NextPart_001_0020_01C8D3B6.F05C5270\r
+Content-Type: text/plain;\r
+       charset="iso-8859-1"\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+This is  a new ticket with attachments\r
+------=_NextPart_001_0020_01C8D3B6.F05C5270\r
+Content-Type: text/html;\r
+       charset="iso-8859-1"\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">\r
+<HTML><HEAD>\r
+<META http-equiv=3DContent-Type content=3D"text/html; =\r
+charset=3Diso-8859-1">\r
+<META content=3D"MSHTML 6.00.2900.2883" name=3DGENERATOR>\r
+<STYLE></STYLE>\r
+</HEAD>\r
+<BODY bgColor=3D#ffffff>\r
+<DIV><FONT face=3DArial size=3D2>This is&nbsp; a new ticket with=20\r
+attachments</FONT></DIV></BODY></HTML>\r
+\r
+------=_NextPart_001_0020_01C8D3B6.F05C5270--\r
+\r
+------=_NextPart_000_001F_01C8D3B6.F05C5270\r
+Content-Type: image/jpeg;\r
+       name="Paella.jpg"\r
+Content-Transfer-Encoding: base64\r
+Content-Disposition: attachment;\r
+       filename="Paella.jpg"\r
+\r
+/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcU\r
+FhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgo\r
+KCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCACmAMgDASIA\r
+AhEBAxEB/8QAHQAAAgMBAQEBAQAAAAAAAAAABQYABAcDCAIBCf/EADsQAAEDAwMCBQIDBQcFAQAA\r
+AAECAwQABREGEiExQQcTIlFhcYEUMpEVI0Kh0QhSYrHB4fAWJCUzQ3L/xAAaAQADAQEBAQAAAAAA\r
+AAAAAAADBAUCAQYA/8QAKhEAAgIBBAICAgIDAAMAAAAAAQIAAxEEEiExIkEFE1FhMnFCkaEjwdH/\r
+2gAMAwEAAhEDEQA/ACTUdSsdhRCNE54GTRaBaXHiBtNOVo0wEpSt8BK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iIEr9z\r
+IjK/K4g9fvR/xBsyLDqF+IwsrjqSl5rd1CFjcAfkZqVKHYIZOonyclpZz0oeygoUpWetSpWVmz1O\r
+c6Ol9o9lDoaBIkPMOZS4obTg4URUqUzWAeDE7SVPEYrXrSZb30ORGwhwDG4rUr/M0SXri+SpYcYu\r
+EiMMcJbVx9alSgtpad27aMw6ai0pjdKFz1nqJuSn/wAtIJIznj+lfQu11VueVdJm9weohwjNSpWj\r
+UigYAmfsck8wPPlPKz5jzyz33LJoOt1SieSB7VKlGQQDk5n2w35qwCaYLbEQEBwgY7CpUrlphaAC\r
+3MIkBKc0DuUUKC5CcJIPI96lSh18GH1AyINiI8x9CM4x3Fat4f6okWOY0qKkFv8AKpCgCFp75qVK\r
+xqfUY+MUENmMmv7bHbDV5tqPJjTFcsK6pVgE4+Kz68xy41vZUEKPvUqUovDyufKjmfrVmYbiHd6n\r
+cbis+/WpUqUcMZKdF44n/9k=\r
+\r
+------=_NextPart_000_001F_01C8D3B6.F05C5270--\r
+\r
index d0fc68de8a645628e2393ca3d88423a8589ce02d..6bb638f211ba316192b6f7a18770b4e6f272e1e9 100644 (file)
@@ -20,38 +20,52 @@ require File.dirname(__FILE__) + '/../test_helper'
 class MailHandlerTest < Test::Unit::TestCase
   fixtures :users, :projects, :enabled_modules, :roles, :members, :issues, :trackers, :enumerations
   
-  FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures'
-  CHARSET = "utf-8"
-
-  include ActionMailer::Quoting
-
+  FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures/mail_handler'
+  
   def setup
-    ActionMailer::Base.delivery_method = :test
-    ActionMailer::Base.perform_deliveries = true
-    ActionMailer::Base.deliveries = []
-
-    @expected = TMail::Mail.new
-    @expected.set_content_type "text", "plain", { "charset" => CHARSET }
-    @expected.mime_version = '1.0'
+    ActionMailer::Base.deliveries.clear
   end
   
-  def test_add_note_to_issue
-    raw = read_fixture("add_note_to_issue.txt").join
-    MailHandler.receive(raw)
-
-    issue = Issue.find(2)
-    journal = issue.journals.find(:first, :order => "created_on DESC")
-    assert journal
-    assert_equal User.find_by_mail("jsmith@somenet.foo"), journal.user
-    assert_equal "Note added by mail", journal.notes
+  def test_add_issue
+    # This email contains: 'Project: onlinestore'
+    issue = submit_email('ticket_on_given_project.eml')
+    assert issue.is_a?(Issue)
+    assert !issue.new_record?
+    issue.reload
+    assert_equal 'New ticket on a given project', issue.subject
+    assert_equal User.find_by_login('jsmith'), issue.author
+    assert_equal Project.find(2), issue.project
+    assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
+  end
+  
+  def test_add_issue_with_attachment_to_specific_project
+    issue = submit_email('ticket_with_attachment.eml', :project => 'onlinestore')
+    assert issue.is_a?(Issue)
+    assert !issue.new_record?
+    issue.reload
+    assert_equal 'Ticket created by email with attachment', issue.subject
+    assert_equal User.find_by_login('jsmith'), issue.author
+    assert_equal Project.find(2), issue.project
+    assert_equal 'This is  a new ticket with attachments', issue.description
+    # Attachment properties
+    assert_equal 1, issue.attachments.size
+    assert_equal 'Paella.jpg', issue.attachments.first.filename
+    assert_equal 'image/jpeg', issue.attachments.first.content_type
+    assert_equal 10790, issue.attachments.first.filesize
+  end
+  
+  def test_add_issue_note
+    journal = submit_email('ticket_reply.eml')
+    assert journal.is_a?(Journal)
+    assert_equal User.find_by_login('jsmith'), journal.user
+    assert_equal Issue.find(2), journal.journalized
+    assert_equal 'This is reply', journal.notes
   end
 
   private
-    def read_fixture(action)
-      IO.readlines("#{FIXTURES_PATH}/mail_handler/#{action}")
-    end
-
-    def encode(subject)
-      quoted_printable(subject, CHARSET)
-    end
+  
+  def submit_email(filename, options={})
+    raw = IO.read(File.join(FIXTURES_PATH, filename))
+    MailHandler.receive(raw, options)
+  end
 end