[mark_read] first pass at quickly re-enabling this endpoint

This commit is contained in:
Fosco Marotto 2021-01-29 20:20:52 -05:00
parent 75d041af77
commit c84e7e3451
2 changed files with 7 additions and 1 deletions

View File

@ -63,7 +63,8 @@ class Api::BaseController < ApplicationController
end end
def current_resource_owner 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 @current_user ||= Rails.cache.fetch("dk:user:#{doorkeeper_token.resource_owner_id}", expires_in: 25.hours) do
User.find(doorkeeper_token.resource_owner_id) User.find(doorkeeper_token.resource_owner_id)
end end

View File

@ -25,6 +25,11 @@ class Api::V1::NotificationsController < Api::BaseController
end end
def mark_read 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! # current_account.notifications.find(params[:id]).mark_read!
render_empty_success render_empty_success
end end