fix: Crashfix for unauthenticated user

This commit is contained in:
Ramon 2025-06-01 16:34:35 +02:00
parent 71ab3dd7ac
commit 41dd481654

View File

@ -12,8 +12,9 @@ module Invidious::Routes::API::V1::Videos
begin begin
video = get_video(id, region: region) video = get_video(id, region: region)
user = env.get("user").as(User)
if user.preferences.watch_history user = env.get?("user").try &.as?(User)
if user && user.preferences.watch_history
Invidious::Database::Users.mark_watched(user, id) Invidious::Database::Users.mark_watched(user, id)
end end
rescue ex : NotFoundException rescue ex : NotFoundException