include people names in the from field
This commit is contained in:
parent
2185df3f52
commit
75aa3f8f97
8 changed files with 34 additions and 25 deletions
2
Gemfile
2
Gemfile
|
|
@ -78,7 +78,7 @@ gem 'hoptoad_notifier'
|
||||||
gem 'newrelic_rpm', :require => false
|
gem 'newrelic_rpm', :require => false
|
||||||
|
|
||||||
#mail
|
#mail
|
||||||
gem 'messagebus_ruby_api', '0.4.0'
|
gem 'messagebus_ruby_api', '0.4.8'
|
||||||
|
|
||||||
# tags
|
# tags
|
||||||
|
|
||||||
|
|
|
||||||
18
Gemfile.lock
18
Gemfile.lock
|
|
@ -139,7 +139,7 @@ GEM
|
||||||
uuidtools
|
uuidtools
|
||||||
childprocess (0.2.2)
|
childprocess (0.2.2)
|
||||||
ffi (~> 1.0.6)
|
ffi (~> 1.0.6)
|
||||||
closure-compiler (1.1.3)
|
closure-compiler (1.1.4)
|
||||||
cloudfiles (1.4.10)
|
cloudfiles (1.4.10)
|
||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16)
|
||||||
columnize (0.3.4)
|
columnize (0.3.4)
|
||||||
|
|
@ -199,7 +199,7 @@ GEM
|
||||||
nokogiri (~> 1.4.3.1)
|
nokogiri (~> 1.4.3.1)
|
||||||
ruby-hmac
|
ruby-hmac
|
||||||
foreigner (0.9.1)
|
foreigner (0.9.1)
|
||||||
foreman (0.22.0)
|
foreman (0.24.0)
|
||||||
term-ansicolor (~> 1.0.5)
|
term-ansicolor (~> 1.0.5)
|
||||||
thor (>= 0.13.6)
|
thor (>= 0.13.6)
|
||||||
formatador (0.2.1)
|
formatador (0.2.1)
|
||||||
|
|
@ -245,7 +245,7 @@ GEM
|
||||||
i18n (>= 0.4.0)
|
i18n (>= 0.4.0)
|
||||||
mime-types (~> 1.16)
|
mime-types (~> 1.16)
|
||||||
treetop (~> 1.4.8)
|
treetop (~> 1.4.8)
|
||||||
messagebus_ruby_api (0.4.0)
|
messagebus_ruby_api (0.4.8)
|
||||||
mime-types (1.16)
|
mime-types (1.16)
|
||||||
mini_magick (3.2)
|
mini_magick (3.2)
|
||||||
subexec (~> 0.0.4)
|
subexec (~> 0.0.4)
|
||||||
|
|
@ -325,10 +325,10 @@ GEM
|
||||||
oa-more (= 0.2.6)
|
oa-more (= 0.2.6)
|
||||||
oa-oauth (= 0.2.6)
|
oa-oauth (= 0.2.6)
|
||||||
oa-openid (= 0.2.6)
|
oa-openid (= 0.2.6)
|
||||||
open4 (1.1.0)
|
open4 (1.2.0)
|
||||||
orm_adapter (0.0.5)
|
orm_adapter (0.0.5)
|
||||||
parallel (0.5.9)
|
parallel (0.5.9)
|
||||||
parallel_tests (0.6.4)
|
parallel_tests (0.6.7)
|
||||||
parallel
|
parallel
|
||||||
polyglot (0.3.2)
|
polyglot (0.3.2)
|
||||||
pyu-ruby-sasl (0.0.3.3)
|
pyu-ruby-sasl (0.0.3.3)
|
||||||
|
|
@ -422,9 +422,9 @@ GEM
|
||||||
rubyzip
|
rubyzip
|
||||||
settingslogic (2.0.6)
|
settingslogic (2.0.6)
|
||||||
simple_oauth (0.1.5)
|
simple_oauth (0.1.5)
|
||||||
sinatra (1.2.6)
|
sinatra (1.2.7)
|
||||||
rack (~> 1.1)
|
rack (~> 1.1)
|
||||||
tilt (< 2.0, >= 1.2.2)
|
tilt (>= 1.2.2, < 2.0)
|
||||||
sqlite3 (1.3.4)
|
sqlite3 (1.3.4)
|
||||||
subexec (0.0.4)
|
subexec (0.0.4)
|
||||||
systemu (2.4.0)
|
systemu (2.4.0)
|
||||||
|
|
@ -449,7 +449,7 @@ GEM
|
||||||
typhoeus (0.2.4)
|
typhoeus (0.2.4)
|
||||||
mime-types
|
mime-types
|
||||||
mime-types
|
mime-types
|
||||||
tzinfo (0.3.29)
|
tzinfo (0.3.30)
|
||||||
uuidtools (2.1.2)
|
uuidtools (2.1.2)
|
||||||
vegas (0.1.8)
|
vegas (0.1.8)
|
||||||
rack (>= 1.0.0)
|
rack (>= 1.0.0)
|
||||||
|
|
@ -506,7 +506,7 @@ DEPENDENCIES
|
||||||
json (= 1.4.6)
|
json (= 1.4.6)
|
||||||
jwt (= 0.1.3)
|
jwt (= 0.1.3)
|
||||||
linecache (= 0.43)
|
linecache (= 0.43)
|
||||||
messagebus_ruby_api (= 0.4.0)
|
messagebus_ruby_api (= 0.4.8)
|
||||||
mini_magick (= 3.2)
|
mini_magick (= 3.2)
|
||||||
mobile-fu
|
mobile-fu
|
||||||
mock_redis
|
mock_redis
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ module NotificationMailers
|
||||||
@comment = Comment.find_by_id(comment_id)
|
@comment = Comment.find_by_id(comment_id)
|
||||||
|
|
||||||
if mail?
|
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] = truncate(@comment.parent.comment_email_subject, :length => TRUNCATION_LEN)
|
||||||
@headers[:subject] = "Re: #{@headers[:subject]}"
|
@headers[:subject] = "Re: #{@headers[:subject]}"
|
||||||
end
|
end
|
||||||
|
|
@ -18,4 +18,4 @@ module NotificationMailers
|
||||||
@recipient && @sender && @comment
|
@recipient && @sender && @comment
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@ module NotificationMailers
|
||||||
def set_headers(comment_id)
|
def set_headers(comment_id)
|
||||||
@comment = Comment.find(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] = truncate(@comment.parent.comment_email_subject, :length => TRUNCATION_LEN)
|
||||||
@headers[:subject] = "Re: #{@headers[:subject]}"
|
@headers[:subject] = "Re: #{@headers[:subject]}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
module NotificationMailers
|
module NotificationMailers
|
||||||
class ConfirmEmail < NotificationMailers::Base
|
class ConfirmEmail < NotificationMailers::Base
|
||||||
def set_headers
|
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)
|
@headers[:subject] = I18n.t('notifier.confirm_email.subject', :unconfirmed_email => @recipient.unconfirmed_email)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@ module NotificationMailers
|
||||||
@conversation = @message.conversation
|
@conversation = @message.conversation
|
||||||
@participants = @conversation.participants
|
@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] = @conversation.subject.strip
|
||||||
@headers[:subject] = "Re: #{@headers[:subject]}" if @conversation.messages.size > 1
|
@headers[:subject] = "Re: #{@headers[:subject]}" if @conversation.messages.size > 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,4 @@ module NotificationMailers
|
||||||
@headers[:subject] = I18n.t('notifier.started_sharing.subject', :name => @sender.name)
|
@headers[:subject] = I18n.t('notifier.started_sharing.subject', :name => @sender.name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,14 @@
|
||||||
module Messagebus
|
module Messagebus
|
||||||
class Mailer
|
class Mailer
|
||||||
|
unless defined?(MessagebusRubyApi::VERSION)
|
||||||
|
MessagebusRubyApi::VERSION = '0.4.8'
|
||||||
|
end
|
||||||
|
|
||||||
def initialize(api_key)
|
def initialize(api_key)
|
||||||
@client = MessagebusRubyApi::Client.new(AppConfig[:messagebus_api_key])
|
puts "yayayayaayayay"
|
||||||
|
@client = MessagebusRubyApi::Client.new(api_key)
|
||||||
|
puts @client.inspect
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_accessor :settings
|
attr_accessor :settings
|
||||||
|
|
@ -15,13 +21,18 @@ module Messagebus
|
||||||
deliver(message)
|
deliver(message)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def message_parse(string)
|
||||||
|
puts string
|
||||||
|
string.split('<')[0]
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def deliver(message)
|
def deliver(message)
|
||||||
# here we want = {:fromEmail => message['from'].to_s}
|
# 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|
|
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?
|
if message.multipart?
|
||||||
m[:plaintextBody] = message.text_part.body.to_s if message.text_part
|
m[:plaintextBody] = message.text_part.body.to_s if message.text_part
|
||||||
|
|
@ -33,12 +44,10 @@ module Messagebus
|
||||||
@client.add_message(m)
|
@client.add_message(m)
|
||||||
end
|
end
|
||||||
|
|
||||||
status = @client.flush
|
|
||||||
|
|
||||||
if status[:failureCount] && status[:failureCount] > 0
|
if status[:failureCount] && status[:failureCount] > 0
|
||||||
|
puts "DOHHHHHHHHHHH"
|
||||||
raise "Messagebus failure. failureCount=#{failureCount}, message=#{message.inspect}"
|
raise "Messagebus failure. failureCount=#{failureCount}, message=#{message.inspect}"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue