Permalink
Browse files

Enable the message_gateway to handle sending all email to a specific …

…user. The current

scanning on to: and from: fields does not work if you bcc Tracks in email. 

site.yml.tmpl is updated to reflect this and removes cas, ldap and openid configs

Also the integrations page is updated to reflect the above
  • Loading branch information...
1 parent 0b1d521 commit 05695c12ea2d18256378fca041d5bed2f0350145 @lrbalt lrbalt committed Jun 28, 2012
@@ -23,11 +23,9 @@ def receive(email)
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 @@ def get_address(email)
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
@@ -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:
</p>
<ul>
- <li>Go to <%= link_to t('layouts.navigation.preferences'), preferences_url %>
- and set your "<%= Preference.human_attribute_name('sms_email') %>" and
+ <li>Go to <%= link_to t('layouts.navigation.preferences'), preferences_url %> and
+ set your "<%= Preference.human_attribute_name('sms_email') %>" and
"<%= Preference.human_attribute_name('sms_context') %>" for todos sent in
via email (which could come from an SMS message)</li>
- <li>In sendmail/qmail/postfix/whatever, set up an email address alias
- to pipe messages to <pre>/PATH/TO/RUBY/ruby /PATH/TO/TRACKS/script/runner -e production 'MessageGateway.receive(STDIN.read)'</pre></li>
+ <li>In sendmail/qmail/postfix/whatever, set up an email address
+ alias to pipe messages to <pre>/usr/bin/bundle exec /PATH/TO/TRACKS/script/rails r -e production 'MessageGateway.receive(STDIN.read)'</pre></li>
<li>Send an email to your newly configured address!</li>
</ul>
<p>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.
</p>
+<p>
+ You may need to configure your <tt>site.yml</tt> to tell the message gateway to look at the <tt>to:</tt> field or <tt>from:</tt> field to
+ lookup Tracks' user from the email address in that field. </p>
+ <p>You can also send all email to a specific Tracks user. Configure mail_dispatch in site.yml to <tt>single_user</tt> and pass the login of the user:
+ <pre>TRACKS_MAIL_RECEIVER=<%=current_user.login%> usr/bin/bundle exec /PATH/TO/TRACKS/script/rails r -e production 'MessageGateway.receive(STDIN.read)'</pre>
+</p>
<a name="google_gadget"> </a>
<h2>Add Tracks as a Google Gmail gadget</h2>
@@ -105,13 +105,19 @@
"<%= Preference.human_attribute_name('sms_context') %>" for todos sent in
via email (which could come from an SMS message)</li>
<li>In sendmail/qmail/postfix/whatever, set up an email address
- alias to pipe messages to <pre>/PATH/TO/RUBY/ruby /PATH/TO/TRACKS/script/runner -e production 'MessageGateway.receive(STDIN.read)'</pre></li>
+ alias to pipe messages to <pre>/usr/bin/bundle exec /PATH/TO/TRACKS/script/rails r -e production 'MessageGateway.receive(STDIN.read)'</pre></li>
<li>Send an email to your newly configured address!</li>
</ul>
<p>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.
</p>
+<p>
+ You may need to configure your <tt>site.yml</tt> to tell the message gateway to look at the <tt>to:</tt> field or <tt>from:</tt> field to
+ lookup Tracks' user from the email address in that field. </p>
+ <p>You can also send all email to a specific Tracks user. Configure mail_dispatch in site.yml to <tt>single_user</tt> and pass the login of the user:
+ <pre>TRACKS_MAIL_RECEIVER=<%=current_user.login%> usr/bin/bundle exec /PATH/TO/TRACKS/script/rails r -e production 'MessageGateway.receive(STDIN.read)'</pre>
+</p>
<a name="google_gadget"> </a>
<h2>Add Tracks as a Google Gmail gadget</h2>
@@ -109,13 +109,19 @@
verzonden zijn via email (die bijv. komen via een SMS message)</li>
<li>In sendmail/qmail/postfix/whatever, stel een email address
alias in om berichten door te sturen naar
- <pre>/PATH/TO/RUBY/ruby /PATH/TO/TRACKS/script/runner -e production 'MessageGateway.receive(STDIN.read)'</pre></li>
+ <pre>/usr/bin/bundle exec /PATH/TO/TRACKS/script/rails r -e production 'MessageGateway.receive(STDIN.read)'</pre></li>
<li>Verstuur een email naar het net geconfigureerde e-mail adres!</li>
</ul>
<p>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.
</p>
+<p>
+ Het kan nodig zijn om jouw <tt>site.yml</tt> te configureren om de message gateway te laten kijken naar het <tt>to:</tt> veld of het <tt>from:</tt> veld om
+ de Tracks-gebruiker op te zoeken met het emailadres uit dat veld. </p>
+ <p>Je kan ook alle email naar een specifieke Tracks gebruiker sturen. Stel mail_dispatch in site.yml in op <tt>single_user</tt> en geeft de login van de gebruiker door:
+ <pre>TRACKS_MAIL_RECEIVER=<%=current_user.login%> usr/bin/bundle exec /PATH/TO/TRACKS/script/rails r -e production 'MessageGateway.receive(STDIN.read)'</pre>
+</p>
<a name="google_gadget"> </a>
<h2>Voeg tracks toe als een Google Gmail gadget</h2>
View
@@ -3,25 +3,15 @@
salt: "change-me"
-# Uncomment ldap or open_id if you want to use those authentication schemes.
-# If you choose ldap, see the additional configuration options further down.
-# NOTE: openid is not supported anymore.
+# NOTE: openid, ldap and cas are currently not supported anymore.
authentication_schemes:
- "database"
- # - "ldap"
- # - "cas"
#set the prefered authentication scheme to display first on the login page
#prefered_auth: database
-# Uncomment if using cas
-#cas_server: "https://cas.demo.edu/cas"
-#cas_server_logout: "https://cas.demo.edu/cas/logout"
-
-
-
# You''ll probably want to change this to the time zone of the computer where Tracks is running
# run rake time:zones:local have Rails suggest time zone names on your system
time_zone: "UTC"
@@ -35,22 +25,21 @@ secure_cookies: false
# rather than the From: address.
# email_dispatch: 'to'
+# If you want to send all email to a specific user, uncomment the following line and
+# set the environment variable TRACKS_MAIL_RECEIVER to the login name of the user that
+# will receive all email
+# email_dispatch: 'single_user'
+
# Set this to the subdirectory you're hosting tracks in and uncomment if applicable
# NOTE: you will also need to set up your web server to deal with the relative
# URL. Mongrel, for example, has a --prefix option.
# subdir: "/tracks"
+
# Set to true to allow anyone to sign up for a username.
open_signups: false
-# Only needed if ldap is included in authentication_schemes
-# ldap:
-# library: 'net/ldap'
-# servers:
-# - 'localhost'
-# use_ssl: false
-# login_format: 'cn=%s,dc=example,dc=com'
# When integrating your tracks instance with http://cloudmailin.com/ by using the /integrations/cloudmailin URL,
# this value is the cloudmailin-secret for verifying the authenticity of the request.

0 comments on commit 05695c1

Please sign in to comment.