diff --git a/app/controllers/access_controller.rb b/app/controllers/access_controller.rb index c48ac418..4be25171 100644 --- a/app/controllers/access_controller.rb +++ b/app/controllers/access_controller.rb @@ -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 diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 59a2175a..c73b28f2 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -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 diff --git a/app/views/map_mailer/access_request_email.html.erb b/app/views/map_mailer/access_request_email.html.erb index b620d40b..2e89eb6e 100644 --- a/app/views/map_mailer/access_request_email.html.erb +++ b/app/views/map_mailer/access_request_email.html.erb @@ -1,26 +1,16 @@ - - -
- - - +<%= @request.user.name %> is requesting access to collaboratively edit the following map:
-<%= @request.user.name %> is requesting access to collaboratively edit the following map:
+<%= @map.name %>
-<%= @map.name %>
+<%= 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;" %> +
<%= 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;" %>
-<%= 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;" %> -
<%= 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;" %>
+ <%= 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 %> +Make sense with Metamaps
-Make sense with Metamaps
- - <%= render partial: 'shared/mailer_unsubscribe_link' %> -<%= @inviter.name %> has invited you to collaboratively edit the following map:
+<%= link_to @map.name, map_url(@map), target: "_blank", style: "font-size: 18px; text-decoration: none; color: #4fc059;" %>
+ <% if @map.desc %> +<%= @map.desc %>
+ <% end %> -<%= @inviter.name %> has invited you to collaboratively edit the following map:
-<%= link_to @map.name, map_url(@map), target: "_blank", style: "font-size: 18px; text-decoration: none; color: #4fc059;" %>
- <% if @map.desc %> -<%= @map.desc %>
- <% 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 %> +Make sense with Metamaps
-Make sense with Metamaps
- - <%= render partial: 'shared/mailer_unsubscribe_link' %> -