From 75aa3f8f972d46d22afbcc87c0bee0c37b0fd299 Mon Sep 17 00:00:00 2001 From: Maxwell Salzberg Date: Wed, 5 Oct 2011 17:12:11 -0700 Subject: [PATCH] include people names in the from field --- Gemfile | 2 +- Gemfile.lock | 18 ++++++++-------- .../notification_mailers/also_commented.rb | 4 ++-- .../notification_mailers/comment_on_post.rb | 4 ++-- .../notification_mailers/confirm_email.rb | 4 ++-- .../notification_mailers/private_message.rb | 4 ++-- .../notification_mailers/started_sharing.rb | 2 +- lib/messagebus/mailer.rb | 21 +++++++++++++------ 8 files changed, 34 insertions(+), 25 deletions(-) diff --git a/Gemfile b/Gemfile index bc9a0ca9e..c7bb0be6e 100644 --- a/Gemfile +++ b/Gemfile @@ -78,7 +78,7 @@ gem 'hoptoad_notifier' gem 'newrelic_rpm', :require => false #mail -gem 'messagebus_ruby_api', '0.4.0' +gem 'messagebus_ruby_api', '0.4.8' # tags diff --git a/Gemfile.lock b/Gemfile.lock index 499f186cb..68bab4162 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -139,7 +139,7 @@ GEM uuidtools childprocess (0.2.2) ffi (~> 1.0.6) - closure-compiler (1.1.3) + closure-compiler (1.1.4) cloudfiles (1.4.10) mime-types (>= 1.16) columnize (0.3.4) @@ -199,7 +199,7 @@ GEM nokogiri (~> 1.4.3.1) ruby-hmac foreigner (0.9.1) - foreman (0.22.0) + foreman (0.24.0) term-ansicolor (~> 1.0.5) thor (>= 0.13.6) formatador (0.2.1) @@ -245,7 +245,7 @@ GEM i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) - messagebus_ruby_api (0.4.0) + messagebus_ruby_api (0.4.8) mime-types (1.16) mini_magick (3.2) subexec (~> 0.0.4) @@ -325,10 +325,10 @@ GEM oa-more (= 0.2.6) oa-oauth (= 0.2.6) oa-openid (= 0.2.6) - open4 (1.1.0) + open4 (1.2.0) orm_adapter (0.0.5) parallel (0.5.9) - parallel_tests (0.6.4) + parallel_tests (0.6.7) parallel polyglot (0.3.2) pyu-ruby-sasl (0.0.3.3) @@ -422,9 +422,9 @@ GEM rubyzip settingslogic (2.0.6) simple_oauth (0.1.5) - sinatra (1.2.6) + sinatra (1.2.7) rack (~> 1.1) - tilt (< 2.0, >= 1.2.2) + tilt (>= 1.2.2, < 2.0) sqlite3 (1.3.4) subexec (0.0.4) systemu (2.4.0) @@ -449,7 +449,7 @@ GEM typhoeus (0.2.4) mime-types mime-types - tzinfo (0.3.29) + tzinfo (0.3.30) uuidtools (2.1.2) vegas (0.1.8) rack (>= 1.0.0) @@ -506,7 +506,7 @@ DEPENDENCIES json (= 1.4.6) jwt (= 0.1.3) linecache (= 0.43) - messagebus_ruby_api (= 0.4.0) + messagebus_ruby_api (= 0.4.8) mini_magick (= 3.2) mobile-fu mock_redis diff --git a/app/mailers/notification_mailers/also_commented.rb b/app/mailers/notification_mailers/also_commented.rb index b5cbff762..8afa2498d 100644 --- a/app/mailers/notification_mailers/also_commented.rb +++ b/app/mailers/notification_mailers/also_commented.rb @@ -8,7 +8,7 @@ module NotificationMailers @comment = Comment.find_by_id(comment_id) if mail? - @headers[:from] = "[#{@comment.author.name} (Diaspora)] <#{AppConfig[:smtp_sender_address]}>" + @headers[:from] = "#{@comment.author.name} (Diaspora*) <#{AppConfig[:smtp_sender_address]}>" @headers[:subject] = truncate(@comment.parent.comment_email_subject, :length => TRUNCATION_LEN) @headers[:subject] = "Re: #{@headers[:subject]}" end @@ -18,4 +18,4 @@ module NotificationMailers @recipient && @sender && @comment end end -end \ No newline at end of file +end diff --git a/app/mailers/notification_mailers/comment_on_post.rb b/app/mailers/notification_mailers/comment_on_post.rb index 4dcf1bfee..89be9e980 100644 --- a/app/mailers/notification_mailers/comment_on_post.rb +++ b/app/mailers/notification_mailers/comment_on_post.rb @@ -7,9 +7,9 @@ module NotificationMailers def set_headers(comment_id) @comment = Comment.find(comment_id) - @headers[:from] = "[#{@comment.author.name} (Diaspora)] <#{AppConfig[:smtp_sender_address]}>" + @headers[:from] = "#{@comment.author.name} (Diaspora*) <#{AppConfig[:smtp_sender_address]}>" @headers[:subject] = truncate(@comment.parent.comment_email_subject, :length => TRUNCATION_LEN) @headers[:subject] = "Re: #{@headers[:subject]}" end end -end \ No newline at end of file +end diff --git a/app/mailers/notification_mailers/confirm_email.rb b/app/mailers/notification_mailers/confirm_email.rb index e9c1d4c6f..fdd71ed79 100644 --- a/app/mailers/notification_mailers/confirm_email.rb +++ b/app/mailers/notification_mailers/confirm_email.rb @@ -1,8 +1,8 @@ module NotificationMailers class ConfirmEmail < NotificationMailers::Base def set_headers - @headers[:to] = "\"#{recipient_name}\" <#{@recipient.unconfirmed_email}>" + @headers[:to] = "#{recipient_name} <#{@recipient.unconfirmed_email}>" @headers[:subject] = I18n.t('notifier.confirm_email.subject', :unconfirmed_email => @recipient.unconfirmed_email) end end -end \ No newline at end of file +end diff --git a/app/mailers/notification_mailers/private_message.rb b/app/mailers/notification_mailers/private_message.rb index 69823f4f3..72fb46e35 100644 --- a/app/mailers/notification_mailers/private_message.rb +++ b/app/mailers/notification_mailers/private_message.rb @@ -7,9 +7,9 @@ module NotificationMailers @conversation = @message.conversation @participants = @conversation.participants - @headers[:from] = "[#{@message.author.name} (Diaspora)] <#{AppConfig[:smtp_sender_address]}>" + @headers[:from] = "#{@message.author.name} (Diaspora*) <#{AppConfig[:smtp_sender_address]}>" @headers[:subject] = @conversation.subject.strip @headers[:subject] = "Re: #{@headers[:subject]}" if @conversation.messages.size > 1 end end -end \ No newline at end of file +end diff --git a/app/mailers/notification_mailers/started_sharing.rb b/app/mailers/notification_mailers/started_sharing.rb index b5922cfff..e02c50e43 100644 --- a/app/mailers/notification_mailers/started_sharing.rb +++ b/app/mailers/notification_mailers/started_sharing.rb @@ -4,4 +4,4 @@ module NotificationMailers @headers[:subject] = I18n.t('notifier.started_sharing.subject', :name => @sender.name) end end -end \ No newline at end of file +end diff --git a/lib/messagebus/mailer.rb b/lib/messagebus/mailer.rb index fab226332..65a6b1fe1 100644 --- a/lib/messagebus/mailer.rb +++ b/lib/messagebus/mailer.rb @@ -1,8 +1,14 @@ module Messagebus class Mailer + unless defined?(MessagebusRubyApi::VERSION) + MessagebusRubyApi::VERSION = '0.4.8' + end def initialize(api_key) - @client = MessagebusRubyApi::Client.new(AppConfig[:messagebus_api_key]) + puts "yayayayaayayay" + @client = MessagebusRubyApi::Client.new(api_key) + puts @client.inspect + end attr_accessor :settings @@ -15,13 +21,18 @@ module Messagebus deliver(message) end + def message_parse(string) + puts string + string.split('<')[0] + end + private def deliver(message) # here we want = {:fromEmail => message['from'].to_s} - @client.common_info = {:fromEmail => message.from.first} + @client.send_common_info = {:fromEmail => message.from.first, :customHeaders => {"sender"=> message['from'].to_s}} message.to.each do |addressee| - m = {:toEmail => addressee, :subject => message.subject} + m = {:toEmail => addressee, :subject => message.subject, :fromName => message_parse(message['from'].to_s)} if message.multipart? m[:plaintextBody] = message.text_part.body.to_s if message.text_part @@ -33,12 +44,10 @@ module Messagebus @client.add_message(m) end - status = @client.flush - if status[:failureCount] && status[:failureCount] > 0 + puts "DOHHHHHHHHHHH" raise "Messagebus failure. failureCount=#{failureCount}, message=#{message.inspect}" end - end end end