mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-03 15:58:50 +01:00
Use Rich Todo API for Message Gateway
This commit is contained in:
parent
3353626016
commit
6e4258cfbc
2 changed files with 5 additions and 92 deletions
|
|
@ -28,35 +28,7 @@ class MessageGateway < ActionMailer::Base
|
|||
# stupid T-Mobile often sends the same message multiple times
|
||||
return if user.todos.find(:first, :conditions => {:description => description})
|
||||
|
||||
# parse context
|
||||
context_data = description.match(/^([^ ]*): (.*)/)
|
||||
if context_data
|
||||
context_name = context_data[1]
|
||||
custom_context = user.contexts.find(:first, :conditions => {:name => context_name})
|
||||
if custom_context
|
||||
context = custom_context
|
||||
description = context_data[2]
|
||||
end
|
||||
end
|
||||
|
||||
# parse due date
|
||||
due_regex = / ?due:([0-9\/-]{3,})/
|
||||
due_date = description.match(due_regex)[1] rescue nil
|
||||
if due_date
|
||||
#strip from description
|
||||
description.sub!(due_regex, '').strip!
|
||||
end
|
||||
|
||||
# parse due date
|
||||
show_regex = / ?show:([0-9\/-]{3,})/
|
||||
show_date = description.match(show_regex)[1] rescue nil
|
||||
if show_date
|
||||
#strip from description
|
||||
description.sub!(show_regex, '').strip!
|
||||
end
|
||||
|
||||
# p "creating todo with description '#{description}', show from #{show_date}, context #{context.name}"
|
||||
todo = user.todos.create(:context => context, :description => description, :notes => notes, :due => due_date, :show_from => show_date)
|
||||
# p todo.validate
|
||||
todo = Todo.from_rich_message(user, context.id, description, notes)
|
||||
todo.save!
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue