Project

General

Profile

RE: Multiple task Creation With Replies on Incomming Mail » mail_handler.patch

Patch with the code for the mail handling - Diego Suárez García, 2011-09-28 10:51

View differences:

mail_handler.rb 2011-09-26 15:51:21.000000000 +0200
100 100
    elsif m = email.subject.match(MESSAGE_REPLY_SUBJECT_RE)
101 101
      receive_message_reply(m[1].to_i)
102 102
    else
103
      dispatch_to_default
103
      #dsuarez: echamos el ojo a ver si el asunto coincide con alguna incidencia abierta reciente (modificada hace menos de dos semanas) 
104
      recientes = Issue.open.find(:all, :conditions=>['updated_on > ?',15.days.ago], :order=>'updated_on ASC').collect{|x| [x.id, x.subject]}
105
      match_incidencia = 0 
106
      recientes.each do |pair| 
107
        match_incidencia = pair[0] if email.subject.match(/^(re:|rv:|fwd:) #{Regexp.quote(pair[1])}/i)                                                                          
108
      end 
109
      if match_incidencia !=0 
110
         receive_issue_reply(match_incidencia.to_i)
111
      else
112
       dispatch_to_default
113
      end
104 114
    end
105 115
  rescue ActiveRecord::RecordInvalid => e
106 116
    # TODO: send a email to the user
    (1-1/1)