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