Mark notification as read when visiting service settings

This commit is contained in:
Karina Kwiatek 2023-01-01 23:58:21 +01:00
parent baffd05d6f
commit d320a74045
1 changed files with 7 additions and 0 deletions

View File

@ -2,6 +2,7 @@
class ServicesController < ApplicationController
before_action :authenticate_user!
before_action :mark_notifications_as_read, only: %i[index]
def index
@services = current_user.services
@ -59,4 +60,10 @@ class ServicesController < ApplicationController
def omniauth_hash
request.env["omniauth.auth"]
end
def mark_notifications_as_read
Notification::ServiceTokenExpired
.where(recipient: current_user, new: true)
.update_all(new: false) # rubocop:disable Rails/SkipsModelValidations
end
end