DB: playlists: make that 'insert' never raises

pull/2845/head
Samantaz Fox 3 years ago
parent c78f84d5c6
commit 714a001332
No known key found for this signature in database
GPG Key ID: F42821059186176E

@ -94,17 +94,13 @@ module Invidious::Database::Playlists
# Salect
# -------------------
def select(*, id : String, raise_on_fail : Bool = false) : InvidiousPlaylist?
def select(*, id : String) : InvidiousPlaylist?
request = <<-SQL
SELECT * FROM playlists
WHERE id = $1
SQL
if raise_on_fail
return PG_DB.query_one(request, id, as: InvidiousPlaylist)
else
return PG_DB.query_one?(request, id, as: InvidiousPlaylist)
end
return PG_DB.query_one?(request, id, as: InvidiousPlaylist)
end
def select_all(*, author : String) : Array(InvidiousPlaylist)

@ -151,12 +151,8 @@ module Invidious::Routes::Playlists
page = env.params.query["page"]?.try &.to_i?
page ||= 1
begin
playlist = Invidious::Database::Playlists.select(id: plid, raise_on_fail: true)
if !playlist || playlist.author != user.email
return env.redirect referer
end
rescue ex
playlist = Invidious::Database::Playlists.select(id: plid)
if !playlist || playlist.author != user.email
return env.redirect referer
end
@ -235,12 +231,8 @@ module Invidious::Routes::Playlists
page = env.params.query["page"]?.try &.to_i?
page ||= 1
begin
playlist = Invidious::Database::Playlists.select(id: plid, raise_on_fail: true)
if !playlist || playlist.author != user.email
return env.redirect referer
end
rescue ex
playlist = Invidious::Database::Playlists.select(id: plid)
if !playlist || playlist.author != user.email
return env.redirect referer
end

Loading…
Cancel
Save