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

View file

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