Merge pull request #6909 from svbergerem/remove-messagebus
Remove messagebus_ruby_api gem
This commit is contained in:
commit
73a49ec78d
5 changed files with 2 additions and 58 deletions
1
Gemfile
1
Gemfile
|
|
@ -126,7 +126,6 @@ gem "rails-i18n", "4.0.8"
|
||||||
# Mail
|
# Mail
|
||||||
|
|
||||||
gem "markerb", "1.1.0"
|
gem "markerb", "1.1.0"
|
||||||
gem "messagebus_ruby_api", "1.0.3"
|
|
||||||
|
|
||||||
# Map
|
# Map
|
||||||
gem "leaflet-rails", "0.7.7"
|
gem "leaflet-rails", "0.7.7"
|
||||||
|
|
|
||||||
|
|
@ -503,7 +503,6 @@ GEM
|
||||||
markerb (1.1.0)
|
markerb (1.1.0)
|
||||||
memoizable (0.4.2)
|
memoizable (0.4.2)
|
||||||
thread_safe (~> 0.3, >= 0.3.1)
|
thread_safe (~> 0.3, >= 0.3.1)
|
||||||
messagebus_ruby_api (1.0.3)
|
|
||||||
method_source (0.8.2)
|
method_source (0.8.2)
|
||||||
mime-types (3.1)
|
mime-types (3.1)
|
||||||
mime-types-data (~> 3.2015)
|
mime-types-data (~> 3.2015)
|
||||||
|
|
@ -966,7 +965,6 @@ DEPENDENCIES
|
||||||
leaflet-rails (= 0.7.7)
|
leaflet-rails (= 0.7.7)
|
||||||
logging-rails (= 0.5.0)
|
logging-rails (= 0.5.0)
|
||||||
markerb (= 1.1.0)
|
markerb (= 1.1.0)
|
||||||
messagebus_ruby_api (= 1.0.3)
|
|
||||||
mini_magick (= 4.5.1)
|
mini_magick (= 4.5.1)
|
||||||
minitest
|
minitest
|
||||||
mobile-fu (= 1.3.1)
|
mobile-fu (= 1.3.1)
|
||||||
|
|
|
||||||
|
|
@ -574,8 +574,7 @@ configuration: ## Section
|
||||||
#sender_address: 'no-reply@example.org'
|
#sender_address: 'no-reply@example.org'
|
||||||
|
|
||||||
## This selects which mailer should be used. Use 'smtp' for a smtp
|
## This selects which mailer should be used. Use 'smtp' for a smtp
|
||||||
## connection, 'sendmail' to use the sendmail binary or
|
## connection or 'sendmail' to use the sendmail binary.
|
||||||
## 'messagebus' to use the messagebus service.
|
|
||||||
#method: 'smtp'
|
#method: 'smtp'
|
||||||
|
|
||||||
## Ignore if method isn't 'smtp'.
|
## Ignore if method isn't 'smtp'.
|
||||||
|
|
@ -618,9 +617,6 @@ configuration: ## Section
|
||||||
## Use exim and sendmail (default=false)
|
## Use exim and sendmail (default=false)
|
||||||
#exim_fix: false
|
#exim_fix: false
|
||||||
|
|
||||||
## Ignore if method isn't 'messagebus'
|
|
||||||
#message_bus_api_key: 'abcdef'
|
|
||||||
|
|
||||||
## Administrator settings
|
## Administrator settings
|
||||||
admins: ## Section
|
admins: ## Section
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,12 @@
|
||||||
# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||||
# licensed under the Affero General Public License version 3 or later. See
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
require Rails.root.join('lib', 'messagebus', 'mailer')
|
|
||||||
|
|
||||||
Diaspora::Application.configure do
|
Diaspora::Application.configure do
|
||||||
config.action_mailer.perform_deliveries = AppConfig.mail.enable?
|
config.action_mailer.perform_deliveries = AppConfig.mail.enable?
|
||||||
|
|
||||||
unless Rails.env == 'test' || !AppConfig.mail.enable?
|
unless Rails.env == 'test' || !AppConfig.mail.enable?
|
||||||
if AppConfig.mail.method == 'messagebus'
|
if AppConfig.mail.method == "sendmail"
|
||||||
|
|
||||||
if AppConfig.mail.message_bus_api_key.present?
|
|
||||||
config.action_mailer.delivery_method = Messagebus::Mailer.new(AppConfig.mail.message_bus_api_key.get)
|
|
||||||
config.action_mailer.raise_delivery_errors = true
|
|
||||||
else
|
|
||||||
puts "You need to set your messagebus api key if you are going to use the message bus service. no mailer is now configured"
|
|
||||||
end
|
|
||||||
elsif AppConfig.mail.method == "sendmail"
|
|
||||||
config.action_mailer.delivery_method = :sendmail
|
config.action_mailer.delivery_method = :sendmail
|
||||||
sendmail_settings = {
|
sendmail_settings = {
|
||||||
location: AppConfig.mail.sendmail.location.get
|
location: AppConfig.mail.sendmail.location.get
|
||||||
|
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
module Messagebus
|
|
||||||
class Mailer
|
|
||||||
def initialize(api_key)
|
|
||||||
@client = MessagebusApi::Messagebus.new(api_key)
|
|
||||||
end
|
|
||||||
|
|
||||||
attr_accessor :settings
|
|
||||||
|
|
||||||
def new(*settings)
|
|
||||||
self.settings = {}
|
|
||||||
self
|
|
||||||
end
|
|
||||||
|
|
||||||
def from_header_parse(string)
|
|
||||||
string.split('<')[0].delete('"')
|
|
||||||
end
|
|
||||||
|
|
||||||
def deliver(message)
|
|
||||||
deliver!(message)
|
|
||||||
end
|
|
||||||
|
|
||||||
def deliver!(message)
|
|
||||||
msg = {:toEmail => message.to.first, :subject => message.subject, :fromEmail => AppConfig.mail.sender_address, :fromName => from_header_parse(message[:from].to_s)}
|
|
||||||
|
|
||||||
if message.multipart?
|
|
||||||
msg[:plaintextBody] = message.text_part.body.to_s if message.text_part
|
|
||||||
msg[:htmlBody] = message.html_part.body.to_s if message.html_part
|
|
||||||
else
|
|
||||||
msg[:plaintextBody] = message.body.to_s
|
|
||||||
msg[:htmlBody] = message.body.to_s
|
|
||||||
end
|
|
||||||
|
|
||||||
begin
|
|
||||||
@client.add_message(msg, true)
|
|
||||||
rescue => message_bus_api_error
|
|
||||||
raise "Messagebus API error=#{message_bus_api_error}, message=#{msg.inspect}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Loading…
Reference in a new issue