diff --git a/app/models/message_gateway.rb b/app/models/message_gateway.rb index e3a4adc8..eaea3818 100644 --- a/app/models/message_gateway.rb +++ b/app/models/message_gateway.rb @@ -23,11 +23,9 @@ class MessageGateway < ActionMailer::Base end end - # stupid T-Mobile often sends the same message multiple times - return if user.todos.where(:description => description).first - todo = Todo.from_rich_message(user, context.id, description, notes) todo.save! + Rails.logger.info "Saved email as todo for user #{user.login} in context #{context.name}" end private @@ -37,10 +35,18 @@ class MessageGateway < ActionMailer::Base end def get_user_from_email_address(email) - address = get_address(email) - user = User.where("preferences.sms_email" => address.strip).includes(:preference).first - if user.nil? - user = User.where("preferences.sms_email" => address.strip[1.100]).includes(:preference).first + if SITE_CONFIG['email_dispatch'] == 'single_user' + Rails.logger.info "All received email goes to #{ENV['TRACKS_MAIL_RECEIVER']}" + user = User.find_by_login(ENV['TRACKS_MAIL_RECEIVER']) + Rails.logger.info "WARNING: Unknown user set for TRACKS_MAIL_RECEIVER (#{ENV['TRACKS_MAIL_RECEIVER']})" if user.nil? + else + address = get_address(email) + Rails.logger.info "Looking for user with email #{address}" + user = User.where("preferences.sms_email" => address.strip).includes(:preference).first + if user.nil? + user = User.where("preferences.sms_email" => address.strip[1.100]).includes(:preference).first + end + Rails.logger.info(!user.nil? ? "Email belongs to #{user.login}" : "User unknown") end return user end diff --git a/app/views/integrations/index.de.html.erb b/app/views/integrations/index.de.html.erb index 3f701411..04850541 100644 --- a/app/views/integrations/index.de.html.erb +++ b/app/views/integrations/index.de.html.erb @@ -100,18 +100,24 @@ If Tracks is running on the same server as your mail server, you can use the integrated mail handler built into tracks. Steps to set it up:
/PATH/TO/RUBY/ruby /PATH/TO/TRACKS/script/runner -e production 'MessageGateway.receive(STDIN.read)'
/usr/bin/bundle exec /PATH/TO/TRACKS/script/rails r -e production 'MessageGateway.receive(STDIN.read)'
You can also use the Rich Todo API to send in tasks like "do laundry @ Home" or "Call Bill > project X". The subject of the message will fill description, context, and project, while the body will populate the tasks's note.
++ You may need to configure your site.yml to tell the message gateway to look at the to: field or from: field to + lookup Tracks' user from the email address in that field.
+You can also send all email to a specific Tracks user. Configure mail_dispatch in site.yml to single_user and pass the login of the user: +
TRACKS_MAIL_RECEIVER=<%=current_user.login%> usr/bin/bundle exec /PATH/TO/TRACKS/script/rails r -e production 'MessageGateway.receive(STDIN.read)'+
/PATH/TO/RUBY/ruby /PATH/TO/TRACKS/script/runner -e production 'MessageGateway.receive(STDIN.read)'
/usr/bin/bundle exec /PATH/TO/TRACKS/script/rails r -e production 'MessageGateway.receive(STDIN.read)'
You can also use the Rich Todo API to send in tasks like "do laundry @ Home" or "Call Bill > project X". The subject of the message will fill description, context, and project, while the body will populate the tasks's note.
++ You may need to configure your site.yml to tell the message gateway to look at the to: field or from: field to + lookup Tracks' user from the email address in that field.
+You can also send all email to a specific Tracks user. Configure mail_dispatch in site.yml to single_user and pass the login of the user: +
TRACKS_MAIL_RECEIVER=<%=current_user.login%> usr/bin/bundle exec /PATH/TO/TRACKS/script/rails r -e production 'MessageGateway.receive(STDIN.read)'+
/PATH/TO/RUBY/ruby /PATH/TO/TRACKS/script/runner -e production 'MessageGateway.receive(STDIN.read)'
/usr/bin/bundle exec /PATH/TO/TRACKS/script/rails r -e production 'MessageGateway.receive(STDIN.read)'
Je kan ook de Rich Todo API gebruiken om acties te maken zoals "do laundry @ Home" of "Call Bill > project X". Het onderwerp van het bericht zal de bijschrijving van de actie vullen, de context, en het project, terwijl de body van het bericht de notities van de actie zal vullen.
++ Het kan nodig zijn om jouw site.yml te configureren om de message gateway te laten kijken naar het to: veld of het from: veld om + de Tracks-gebruiker op te zoeken met het emailadres uit dat veld.
+Je kan ook alle email naar een specifieke Tracks gebruiker sturen. Stel mail_dispatch in site.yml in op single_user en geeft de login van de gebruiker door: +
TRACKS_MAIL_RECEIVER=<%=current_user.login%> usr/bin/bundle exec /PATH/TO/TRACKS/script/rails r -e production 'MessageGateway.receive(STDIN.read)'+