partial support for history details in history page
This commit is contained in:
parent
ee6d2b5620
commit
7f16feaff6
3 changed files with 13 additions and 7 deletions
|
@ -49,14 +49,14 @@ module Invidious::Database::Users
|
||||||
PG_DB.exec(request, user.watched, user.email)
|
PG_DB.exec(request, user.watched, user.email)
|
||||||
end
|
end
|
||||||
|
|
||||||
def mark_watched(user : User, vid : String)
|
def mark_watched(user : User, history_details : JSON::Any)
|
||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
UPDATE users
|
UPDATE users
|
||||||
SET watched = array_append(array_remove(watched, $1), $1)
|
SET watched = array_append(array_remove(watched, $1::jsonb), $1::jsonb)
|
||||||
WHERE email = $2
|
WHERE email = $2
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, vid, user.email)
|
PG_DB.exec(request, history_details, user.email)
|
||||||
end
|
end
|
||||||
|
|
||||||
def mark_unwatched(user : User, vid : String)
|
def mark_unwatched(user : User, vid : String)
|
||||||
|
|
|
@ -86,7 +86,7 @@ module Invidious::Routes::API::V1::Authenticated
|
||||||
return error_json(400, "Invalid video id.")
|
return error_json(400, "Invalid video id.")
|
||||||
end
|
end
|
||||||
|
|
||||||
Invidious::Database::Users.mark_watched(user, id)
|
# Invidious::Database::Users.mark_watched(user, id)
|
||||||
env.response.status_code = 204
|
env.response.status_code = 204
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -76,8 +76,14 @@ module Invidious::Routes::Watch
|
||||||
end
|
end
|
||||||
env.params.query.delete_all("iv_load_policy")
|
env.params.query.delete_all("iv_load_policy")
|
||||||
|
|
||||||
|
history_details = JSON::Any.new({
|
||||||
|
"id" => JSON::Any.new(id),
|
||||||
|
"title" => JSON::Any.new(video.title),
|
||||||
|
"author" => JSON::Any.new(video.author)
|
||||||
|
})
|
||||||
|
|
||||||
if watched && preferences.watch_history
|
if watched && preferences.watch_history
|
||||||
Invidious::Database::Users.mark_watched(user.as(User), id)
|
Invidious::Database::Users.mark_watched(user.as(User), history_details)
|
||||||
end
|
end
|
||||||
|
|
||||||
if CONFIG.enable_user_notifications && notifications && notifications.includes? id
|
if CONFIG.enable_user_notifications && notifications && notifications.includes? id
|
||||||
|
@ -286,9 +292,9 @@ module Invidious::Routes::Watch
|
||||||
|
|
||||||
case action
|
case action
|
||||||
when "action_mark_watched"
|
when "action_mark_watched"
|
||||||
Invidious::Database::Users.mark_watched(user, id)
|
# Invidious::Database::Users.mark_watched(user, history_details)
|
||||||
when "action_mark_unwatched"
|
when "action_mark_unwatched"
|
||||||
Invidious::Database::Users.mark_unwatched(user, id)
|
# Invidious::Database::Users.mark_unwatched(user, id)
|
||||||
else
|
else
|
||||||
return error_json(400, "Unsupported action #{action}")
|
return error_json(400, "Unsupported action #{action}")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue