From 9079d1bffc79ff1527871ec4eb086da6238d11aa Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Wed, 8 Mar 2017 15:01:58 -0500 Subject: [PATCH] check permissions prior to sending --- app/services/notification_service.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 177489e1..737dbb4d 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -34,6 +34,11 @@ class NotificationService # we'll prbly want to put the body into the actual loop so we can pass the current user in as a local body = renderer.render(template: settings[:template], locals: { entity: entity, event: event }, layout: false) follows.each{|follow| + if entity.class == Map + next unless MapPolicy.new(follow.user, entity).show? + elsif entity.class == Topic + next unless TopicPolicy.new(follow.user, entity).show? + end # this handles email and in-app notifications, in the future, include push follow.user.notify(settings[:subject], body, event, false, event_type, follow.user.emails_allowed, event.user) # push could be handled with Actioncable to send transient notifications to the UI