Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into test_apps
- Loading branch information
Showing
10 changed files
with
106 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
Gemfile.lock | ||
\#*# | ||
doc/** | ||
pkg/** | ||
coverage.data | ||
pkg | ||
.rvmrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,32 @@ | ||
module ActionMailer | ||
class Base | ||
private | ||
def perform_delivery_bushido(mail) | ||
Bushido::Command.post_command(Bushido::Base.send_email_url, mail) | ||
def perform_delivery_bushido(mail) | ||
if mail.to.nil? | ||
unless logger.nil? | ||
logger.error "This mail isn't addressed to anyone! Dropping" | ||
end | ||
|
||
return false | ||
end | ||
|
||
result = Bushido::App.mail_allowed? | ||
|
||
if result | ||
logger.info result.inspect unless logger.nil? | ||
if result["success"] == true | ||
Bushido::SMTP.setup_action_mailer_smtp! | ||
|
||
unless logger.nil? | ||
logger.info "App allowed to send email, sending via SMTP" | ||
__send__("perform_delivery_smtp", mail) if perform_deliveries | ||
end | ||
else | ||
logger.info "Unable to send email: #{result['message']}" unless logger.nil? | ||
end | ||
else | ||
logger.info "Unable to contact Bushido to verify email credentials" unless logger.nil? | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Bushido | ||
class SMTP | ||
class << self | ||
[:tls, :server, :port, :domain, :authentication, :user, :password].each do |method_name| | ||
define_method "#{method_name}".to_sym do | ||
ENV["SMTP_#{method_name.to_s.upcase}"] | ||
end | ||
end | ||
|
||
def setup_action_mailer_smtp! | ||
ActionMailer::Base.smtp_settings = { | ||
:enable_starttls_auto => Bushido::SMTP.tls, | ||
:tls => Bushido::SMTP.tls, | ||
:address => Bushido::SMTP.server, | ||
:port => Bushido::SMTP.port, | ||
:domain => Bushido::SMTP.domain, | ||
:authentication => Bushido::SMTP.authentication, | ||
:user_name => Bushido::SMTP.user, | ||
:password => Bushido::SMTP.password, | ||
} | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
require 'bushido' | ||
require 'rails' | ||
require 'rails/routes' | ||
|
||
module Bushido | ||
class Engine < Rails::Engine | ||
if defined?(Rails) && Rails::VERSION::MAJOR == 3 | ||
require 'rails' | ||
require 'rails/routes' | ||
|
||
module Bushido | ||
class Engine < Rails::Engine | ||
|
||
initializer "bushido.add_middleware" do |app| | ||
|
||
# Only include our middleware if its on our platform | ||
unless ENV['BUSHIDO_APP'].nil? | ||
app.middleware.use Bushido::Middleware | ||
initializer "bushido.add_middleware" do |app| | ||
# Only include our middleware if its on our platform | ||
unless ENV['BUSHIDO_APP'].nil? | ||
app.middleware.use Bushido::Middleware | ||
end | ||
end | ||
end | ||
end | ||
else | ||
# Rails 2 handling | ||
Rails.configuration.middleware.use 'Bushido::Middleware' | ||
end |