fugly integration of map mailers into mailboxer
This commit is contained in:
parent
1d36ee03b2
commit
8267054d89
6 changed files with 43 additions and 64 deletions
|
@ -21,7 +21,8 @@ class AccessController < ApplicationController
|
||||||
def access_request
|
def access_request
|
||||||
request = AccessRequest.create(user: current_user, map: @map)
|
request = AccessRequest.create(user: current_user, map: @map)
|
||||||
# what about push notification to map owner?
|
# what about push notification to map owner?
|
||||||
MapMailer.access_request_email(request, @map).deliver_later
|
mail = MapMailer.access_request_email(request, @map)
|
||||||
|
@map.user.notify(mail.subject, mail.body.parts[0])
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json do
|
format.json do
|
||||||
|
@ -37,7 +38,9 @@ class AccessController < ApplicationController
|
||||||
@map.add_new_collaborators(user_ids).each do |user_id|
|
@map.add_new_collaborators(user_ids).each do |user_id|
|
||||||
# add_new_collaborators returns array of added users,
|
# add_new_collaborators returns array of added users,
|
||||||
# who we then send an email to
|
# who we then send an email to
|
||||||
MapMailer.invite_to_edit_email(@map, current_user, User.find(user_id)).deliver_later
|
user = User.find(user_id)
|
||||||
|
mail = MapMailer.invite_to_edit_email(@map, current_user, User.find(user_id))
|
||||||
|
user.notify(mail.subject, mail.body.parts[0])
|
||||||
end
|
end
|
||||||
@map.remove_old_collaborators(user_ids)
|
@map.remove_old_collaborators(user_ids)
|
||||||
|
|
||||||
|
@ -51,7 +54,7 @@ class AccessController < ApplicationController
|
||||||
# GET maps/:id/approve_access/:request_id
|
# GET maps/:id/approve_access/:request_id
|
||||||
def approve_access
|
def approve_access
|
||||||
request = AccessRequest.find(params[:request_id])
|
request = AccessRequest.find(params[:request_id])
|
||||||
request.approve()
|
request.approve
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to map_path(@map), notice: 'Request was approved' }
|
format.html { redirect_to map_path(@map), notice: 'Request was approved' }
|
||||||
end
|
end
|
||||||
|
@ -60,7 +63,7 @@ class AccessController < ApplicationController
|
||||||
# GET maps/:id/deny_access/:request_id
|
# GET maps/:id/deny_access/:request_id
|
||||||
def deny_access
|
def deny_access
|
||||||
request = AccessRequest.find(params[:request_id])
|
request = AccessRequest.find(params[:request_id])
|
||||||
request.deny()
|
request.deny
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to map_path(@map), notice: 'Request was turned down' }
|
format.html { redirect_to map_path(@map), notice: 'Request was turned down' }
|
||||||
end
|
end
|
||||||
|
@ -69,7 +72,7 @@ class AccessController < ApplicationController
|
||||||
# POST maps/:id/approve_access/:request_id
|
# POST maps/:id/approve_access/:request_id
|
||||||
def approve_access_post
|
def approve_access_post
|
||||||
request = AccessRequest.find(params[:request_id])
|
request = AccessRequest.find(params[:request_id])
|
||||||
request.approve()
|
request.approve
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json do
|
format.json do
|
||||||
head :ok
|
head :ok
|
||||||
|
@ -80,7 +83,7 @@ class AccessController < ApplicationController
|
||||||
# POST maps/:id/deny_access/:request_id
|
# POST maps/:id/deny_access/:request_id
|
||||||
def deny_access_post
|
def deny_access_post
|
||||||
request = AccessRequest.find(params[:request_id])
|
request = AccessRequest.find(params[:request_id])
|
||||||
request.deny()
|
request.deny
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json do
|
format.json do
|
||||||
head :ok
|
head :ok
|
||||||
|
@ -94,5 +97,4 @@ class AccessController < ApplicationController
|
||||||
@map = Map.find(params[:id])
|
@map = Map.find(params[:id])
|
||||||
authorize @map
|
authorize @map
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,4 +2,8 @@
|
||||||
class ApplicationMailer < ActionMailer::Base
|
class ApplicationMailer < ActionMailer::Base
|
||||||
default from: 'team@metamaps.cc'
|
default from: 'team@metamaps.cc'
|
||||||
layout 'mailer'
|
layout 'mailer'
|
||||||
|
|
||||||
|
def deliver
|
||||||
|
fail NotImplementedError('Please use Mailboxer to send your emails.')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,4 @@
|
||||||
<!DOCTYPE html>
|
<div style="padding: 16px; background: white; text-align: left;">
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
|
|
||||||
</head>
|
|
||||||
<body style="font-family: sans-serif; width: 100%; padding: 24px 16px 16px 16px; background-color: #f5f5f5; text-align: center;">
|
|
||||||
|
|
||||||
<div style="padding: 16px; background: white; text-align: left;">
|
|
||||||
<% button_style = "background-color:#4fc059;border-radius:2px;color:white;display:inline-block;font-family:Roboto,Arial,Helvetica,sans-serif;font-size:12px;font-weight:bold;min-height:29px;line-height:29px;min-width:54px;outline:0px;padding:0 8px;text-align:center;text-decoration:none" %>
|
<% button_style = "background-color:#4fc059;border-radius:2px;color:white;display:inline-block;font-family:Roboto,Arial,Helvetica,sans-serif;font-size:12px;font-weight:bold;min-height:29px;line-height:29px;min-width:54px;outline:0px;padding:0 8px;text-align:center;text-decoration:none" %>
|
||||||
|
|
||||||
<p><span style="font-weight: bold;"><%= @request.user.name %></span> is requesting access to <span style="font-weight: bold">collaboratively edit</span> the following map:</p>
|
<p><span style="font-weight: bold;"><%= @request.user.name %></span> is requesting access to <span style="font-weight: bold">collaboratively edit</span> the following map:</p>
|
||||||
|
@ -20,7 +13,4 @@
|
||||||
<p style="font-size: 12px;">Make sense with Metamaps</p>
|
<p style="font-size: 12px;">Make sense with Metamaps</p>
|
||||||
|
|
||||||
<%= render partial: 'shared/mailer_unsubscribe_link' %>
|
<%= render partial: 'shared/mailer_unsubscribe_link' %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
|
@ -1,11 +1,4 @@
|
||||||
<!DOCTYPE html>
|
<div style="padding: 16px; background: white; text-align: left;">
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
|
|
||||||
</head>
|
|
||||||
<body style="font-family: sans-serif; width: 100%; padding: 24px 16px 16px 16px; background-color: #f5f5f5; text-align: center;">
|
|
||||||
|
|
||||||
<div style="padding: 16px; background: white; text-align: left;">
|
|
||||||
<% button_style = "background-color:#4fc059;border-radius:2px;color:white;display:inline-block;font-family:Roboto,Arial,Helvetica,sans-serif;font-size:12px;font-weight:bold;min-height:29px;line-height:29px;min-width:54px;outline:0px;padding:0 8px;text-align:center;text-decoration:none" %>
|
<% button_style = "background-color:#4fc059;border-radius:2px;color:white;display:inline-block;font-family:Roboto,Arial,Helvetica,sans-serif;font-size:12px;font-weight:bold;min-height:29px;line-height:29px;min-width:54px;outline:0px;padding:0 8px;text-align:center;text-decoration:none" %>
|
||||||
|
|
||||||
<p><span style="font-weight: bold;"><%= @inviter.name %></span> has invited you to <span style="font-weight: bold">collaboratively edit</span> the following map:</p>
|
<p><span style="font-weight: bold;"><%= @inviter.name %></span> has invited you to <span style="font-weight: bold">collaboratively edit</span> the following map:</p>
|
||||||
|
@ -19,7 +12,4 @@
|
||||||
<p style="font-size: 12px;">Make sense with Metamaps</p>
|
<p style="font-size: 12px;">Make sense with Metamaps</p>
|
||||||
|
|
||||||
<%= render partial: 'shared/mailer_unsubscribe_link' %>
|
<%= render partial: 'shared/mailer_unsubscribe_link' %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
|
@ -8,14 +8,15 @@ Bundler.require(*Rails.groups)
|
||||||
|
|
||||||
module Metamaps
|
module Metamaps
|
||||||
class Application < Rails::Application
|
class Application < Rails::Application
|
||||||
config.active_job.queue_adapter = :delayed_job
|
|
||||||
if ENV['ACTIVE_JOB_FRAMEWORK'] == 'sucker_punch'
|
|
||||||
config.active_job.queue_adapter = :sucker_punch
|
|
||||||
end
|
|
||||||
|
|
||||||
# Settings in config/environments/* take precedence over those specified here.
|
# Settings in config/environments/* take precedence over those specified here.
|
||||||
# Application configuration should go into files in config/initializers
|
# Application configuration should go into files in config/initializers
|
||||||
# -- all .rb files in that directory are automatically loaded.
|
# -- all .rb files in that directory are automatically loaded.
|
||||||
|
#
|
||||||
|
if ENV['ACTIVE_JOB_FRAMEWORK'] == 'sucker_punch'
|
||||||
|
config.active_job.queue_adapter = :sucker_punch
|
||||||
|
else
|
||||||
|
config.active_job.queue_adapter = :delayed_job
|
||||||
|
end
|
||||||
|
|
||||||
# Custom directories with classes and modules you want to be autoloadable.
|
# Custom directories with classes and modules you want to be autoloadable.
|
||||||
config.autoload_paths << Rails.root.join('app', 'services')
|
config.autoload_paths << Rails.root.join('app', 'services')
|
||||||
|
|
|
@ -14,19 +14,11 @@ Rails.application.configure do
|
||||||
config.consider_all_requests_local = true
|
config.consider_all_requests_local = true
|
||||||
config.action_controller.perform_caching = false
|
config.action_controller.perform_caching = false
|
||||||
|
|
||||||
config.action_mailer.delivery_method = :smtp
|
config.action_mailer.delivery_method = :file
|
||||||
config.action_mailer.smtp_settings = {
|
config.action_mailer.file_settings = {
|
||||||
address: ENV['SMTP_SERVER'],
|
location: 'tmp/mails'
|
||||||
port: ENV['SMTP_PORT'],
|
|
||||||
user_name: ENV['SMTP_USERNAME'],
|
|
||||||
password: ENV['SMTP_PASSWORD'],
|
|
||||||
domain: ENV['SMTP_DOMAIN'],
|
|
||||||
authentication: 'plain',
|
|
||||||
enable_starttls_auto: true,
|
|
||||||
openssl_verify_mode: 'none'
|
|
||||||
}
|
}
|
||||||
config.action_mailer.default_url_options = { host: 'localhost:3000' }
|
config.action_mailer.default_url_options = { host: 'localhost:3000' }
|
||||||
# Don't care if the mailer can't send
|
|
||||||
config.action_mailer.raise_delivery_errors = true
|
config.action_mailer.raise_delivery_errors = true
|
||||||
|
|
||||||
# Print deprecation notices to the Rails logger
|
# Print deprecation notices to the Rails logger
|
||||||
|
|
Loading…
Add table
Reference in a new issue