From 8e958ec9a80688c0efa25b22ebe25e3fba817ee7 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Fri, 9 Dec 2016 11:59:24 -0500 Subject: [PATCH] invite to edit notifications marked as read in system once map is visited --- app/controllers/maps_controller.rb | 1 + app/models/user_map.rb | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/app/controllers/maps_controller.rb b/app/controllers/maps_controller.rb index d66456b8..6e1e0d77 100644 --- a/app/controllers/maps_controller.rb +++ b/app/controllers/maps_controller.rb @@ -8,6 +8,7 @@ class MapsController < ApplicationController def show respond_to do |format| format.html do + UserMap.where(map: @map, user: current_user).map(&:mark_invite_notifications_as_read) @allmappers = @map.contributors @allcollaborators = @map.editors @alltopics = policy_scope(@map.topics) diff --git a/app/models/user_map.rb b/app/models/user_map.rb index dc268047..3aa87b03 100644 --- a/app/models/user_map.rb +++ b/app/models/user_map.rb @@ -2,4 +2,10 @@ class UserMap < ApplicationRecord belongs_to :map belongs_to :user + + def mark_invite_notifications_as_read + Mailboxer::Notification.where(notified_object: self).each do |notification| + Mailboxer::Receipt.where(notification: notification).update_all(is_read: true) + end + end end