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