From c84e7e34516eeb30559e7d89ffedb5a6157f1dfe Mon Sep 17 00:00:00 2001 From: Fosco Marotto Date: Fri, 29 Jan 2021 20:20:52 -0500 Subject: [PATCH] [mark_read] first pass at quickly re-enabling this endpoint --- app/controllers/api/base_controller.rb | 3 ++- app/controllers/api/v1/notifications_controller.rb | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/base_controller.rb b/app/controllers/api/base_controller.rb index 5832683f..0092b2ea 100644 --- a/app/controllers/api/base_controller.rb +++ b/app/controllers/api/base_controller.rb @@ -63,7 +63,8 @@ class Api::BaseController < ApplicationController end def current_resource_owner - return @current_user if doorkeeper_token.nil? + return nil if cookies.signed['_session_id'].nil? + # return @current_user if doorkeeper_token.nil? @current_user ||= Rails.cache.fetch("dk:user:#{doorkeeper_token.resource_owner_id}", expires_in: 25.hours) do User.find(doorkeeper_token.resource_owner_id) end diff --git a/app/controllers/api/v1/notifications_controller.rb b/app/controllers/api/v1/notifications_controller.rb index 00679633..cb3268c6 100644 --- a/app/controllers/api/v1/notifications_controller.rb +++ b/app/controllers/api/v1/notifications_controller.rb @@ -25,6 +25,11 @@ class Api::V1::NotificationsController < Api::BaseController end def mark_read + if !params[:id].nil? and !current_account.user.nil? + conn = ActiveRecord::Base.connection + conn.stick_to_master! + conn.exec_query "update users set last_read_notification = #{params[:id].to_i} where id = #{current_account.user.id}" + end # current_account.notifications.find(params[:id]).mark_read! render_empty_success end