mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-30 05:48:50 +01:00
get all unit tests running again. Seems we have some pretty old code in there :-)
This commit is contained in:
parent
e964769553
commit
fd4fb6df9e
19 changed files with 255 additions and 284 deletions
|
|
@ -1,8 +1,9 @@
|
|||
class MessageGateway < ActionMailer::Base
|
||||
include ActionView::Helpers::SanitizeHelper
|
||||
extend ActionView::Helpers::SanitizeHelper::ClassMethods
|
||||
# include ActionView::Helpers::SanitizeHelper
|
||||
# extend ActionView::Helpers::SanitizeHelper::ClassMethods
|
||||
|
||||
def receive(email)
|
||||
puts "email = #{email}"
|
||||
address = ''
|
||||
if SITE_CONFIG['email_dispatch'] == 'to'
|
||||
address = email.to[0]
|
||||
|
|
@ -10,9 +11,9 @@ class MessageGateway < ActionMailer::Base
|
|||
address = email.from[0]
|
||||
end
|
||||
|
||||
user = User.find(:first, :include => [:preference], :conditions => ["preferences.sms_email = ?", address.strip])
|
||||
user = User.where("preferences.sms_email" => address.strip).first(:include => [:preference])
|
||||
if user.nil?
|
||||
user = User.find(:first, :include => [:preference], :conditions => ["preferences.sms_email = ?", address.strip[1,100]])
|
||||
user = User.where("preferences.sms_email" => address.strip[1.100]).first(:include => [:preference])
|
||||
end
|
||||
return if user.nil?
|
||||
context = user.prefs.sms_context
|
||||
|
|
@ -25,7 +26,7 @@ class MessageGateway < ActionMailer::Base
|
|||
body_part = email.parts.find{|m| m.content_type == "text/plain"}
|
||||
notes = sanitize body_part.body.strip
|
||||
else
|
||||
if email.subject.empty?
|
||||
if email.subject && email.subject.blank?
|
||||
description = sanitize email.body.strip
|
||||
notes = nil
|
||||
else
|
||||
|
|
@ -35,7 +36,7 @@ class MessageGateway < ActionMailer::Base
|
|||
end
|
||||
|
||||
# stupid T-Mobile often sends the same message multiple times
|
||||
return if user.todos.find(:first, :conditions => {:description => description})
|
||||
return if user.todos.where(:description => description).first
|
||||
|
||||
todo = Todo.from_rich_message(user, context.id, description, notes)
|
||||
todo.save!
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue