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
|
||||
request = AccessRequest.create(user: current_user, map: @map)
|
||||
# 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|
|
||||
format.json do
|
||||
|
@ -37,7 +38,9 @@ class AccessController < ApplicationController
|
|||
@map.add_new_collaborators(user_ids).each do |user_id|
|
||||
# add_new_collaborators returns array of added users,
|
||||
# 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
|
||||
@map.remove_old_collaborators(user_ids)
|
||||
|
||||
|
@ -51,7 +54,7 @@ class AccessController < ApplicationController
|
|||
# GET maps/:id/approve_access/:request_id
|
||||
def approve_access
|
||||
request = AccessRequest.find(params[:request_id])
|
||||
request.approve()
|
||||
request.approve
|
||||
respond_to do |format|
|
||||
format.html { redirect_to map_path(@map), notice: 'Request was approved' }
|
||||
end
|
||||
|
@ -60,7 +63,7 @@ class AccessController < ApplicationController
|
|||
# GET maps/:id/deny_access/:request_id
|
||||
def deny_access
|
||||
request = AccessRequest.find(params[:request_id])
|
||||
request.deny()
|
||||
request.deny
|
||||
respond_to do |format|
|
||||
format.html { redirect_to map_path(@map), notice: 'Request was turned down' }
|
||||
end
|
||||
|
@ -69,7 +72,7 @@ class AccessController < ApplicationController
|
|||
# POST maps/:id/approve_access/:request_id
|
||||
def approve_access_post
|
||||
request = AccessRequest.find(params[:request_id])
|
||||
request.approve()
|
||||
request.approve
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
head :ok
|
||||
|
@ -80,7 +83,7 @@ class AccessController < ApplicationController
|
|||
# POST maps/:id/deny_access/:request_id
|
||||
def deny_access_post
|
||||
request = AccessRequest.find(params[:request_id])
|
||||
request.deny()
|
||||
request.deny
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
head :ok
|
||||
|
@ -94,5 +97,4 @@ class AccessController < ApplicationController
|
|||
@map = Map.find(params[:id])
|
||||
authorize @map
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -2,4 +2,8 @@
|
|||
class ApplicationMailer < ActionMailer::Base
|
||||
default from: 'team@metamaps.cc'
|
||||
layout 'mailer'
|
||||
|
||||
def deliver
|
||||
fail NotImplementedError('Please use Mailboxer to send your emails.')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,26 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<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" %>
|
||||
|
||||
<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" %>
|
||||
<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>
|
||||
<p><%= @map.name %></p>
|
||||
|
||||
<p><%= @map.name %></p>
|
||||
<p><%= link_to "Allow", approve_access_map_url(id: @map.id, request_id: @request.id), target: "_blank", style: "font-size: 18px; text-decoration: none; color: #4fc059;" %>
|
||||
<p><%= link_to "Decline", deny_access_map_url(id: @map.id, request_id: @request.id), target: "_blank", style: "font-size: 18px; text-decoration: none; color: #DB5D5D;" %></p>
|
||||
|
||||
<p><%= link_to "Allow", approve_access_map_url(id: @map.id, request_id: @request.id), target: "_blank", style: "font-size: 18px; text-decoration: none; color: #4fc059;" %>
|
||||
<p><%= link_to "Decline", deny_access_map_url(id: @map.id, request_id: @request.id), target: "_blank", style: "font-size: 18px; text-decoration: none; color: #DB5D5D;" %></p>
|
||||
<%= link_to 'Open in Metamaps', map_url(@map), target: "_blank", style: button_style %>
|
||||
|
||||
<%= link_to 'Open in Metamaps', map_url(@map), target: "_blank", style: button_style %>
|
||||
<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' %>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<%= render partial: 'shared/mailer_unsubscribe_link' %>
|
||||
</div>
|
||||
|
|
|
@ -1,25 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<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" %>
|
||||
|
||||
<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" %>
|
||||
<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><%= link_to @map.name, map_url(@map), target: "_blank", style: "font-size: 18px; text-decoration: none; color: #4fc059;" %></p>
|
||||
<% if @map.desc %>
|
||||
<p style="font-size: 12px;"><%= @map.desc %></p>
|
||||
<% end %>
|
||||
|
||||
<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><%= link_to @map.name, map_url(@map), target: "_blank", style: "font-size: 18px; text-decoration: none; color: #4fc059;" %></p>
|
||||
<% if @map.desc %>
|
||||
<p style="font-size: 12px;"><%= @map.desc %></p>
|
||||
<% end %>
|
||||
<%= link_to 'Open in Metamaps', map_url(@map), target: "_blank", style: button_style %>
|
||||
|
||||
<%= link_to 'Open in Metamaps', map_url(@map), target: "_blank", style: button_style %>
|
||||
<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' %>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<%= render partial: 'shared/mailer_unsubscribe_link' %>
|
||||
</div>
|
||||
|
|
|
@ -8,14 +8,15 @@ Bundler.require(*Rails.groups)
|
|||
|
||||
module Metamaps
|
||||
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.
|
||||
# Application configuration should go into files in config/initializers
|
||||
# -- 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.
|
||||
config.autoload_paths << Rails.root.join('app', 'services')
|
||||
|
|
|
@ -14,19 +14,11 @@ Rails.application.configure do
|
|||
config.consider_all_requests_local = true
|
||||
config.action_controller.perform_caching = false
|
||||
|
||||
config.action_mailer.delivery_method = :smtp
|
||||
config.action_mailer.smtp_settings = {
|
||||
address: ENV['SMTP_SERVER'],
|
||||
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.delivery_method = :file
|
||||
config.action_mailer.file_settings = {
|
||||
location: 'tmp/mails'
|
||||
}
|
||||
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
|
||||
|
||||
# Print deprecation notices to the Rails logger
|
||||
|
|
Loading…
Reference in a new issue