mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
DB: playlists: make that 'insert' never raises
This commit is contained in:
parent
c78f84d5c6
commit
714a001332
2 changed files with 6 additions and 18 deletions
|
@ -94,17 +94,13 @@ module Invidious::Database::Playlists
|
||||||
# Salect
|
# Salect
|
||||||
# -------------------
|
# -------------------
|
||||||
|
|
||||||
def select(*, id : String, raise_on_fail : Bool = false) : InvidiousPlaylist?
|
def select(*, id : String) : InvidiousPlaylist?
|
||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
SELECT * FROM playlists
|
SELECT * FROM playlists
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
if raise_on_fail
|
return PG_DB.query_one?(request, id, as: InvidiousPlaylist)
|
||||||
return PG_DB.query_one(request, id, as: InvidiousPlaylist)
|
|
||||||
else
|
|
||||||
return PG_DB.query_one?(request, id, as: InvidiousPlaylist)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def select_all(*, author : String) : Array(InvidiousPlaylist)
|
def select_all(*, author : String) : Array(InvidiousPlaylist)
|
||||||
|
|
|
@ -151,12 +151,8 @@ module Invidious::Routes::Playlists
|
||||||
page = env.params.query["page"]?.try &.to_i?
|
page = env.params.query["page"]?.try &.to_i?
|
||||||
page ||= 1
|
page ||= 1
|
||||||
|
|
||||||
begin
|
playlist = Invidious::Database::Playlists.select(id: plid)
|
||||||
playlist = Invidious::Database::Playlists.select(id: plid, raise_on_fail: true)
|
if !playlist || playlist.author != user.email
|
||||||
if !playlist || playlist.author != user.email
|
|
||||||
return env.redirect referer
|
|
||||||
end
|
|
||||||
rescue ex
|
|
||||||
return env.redirect referer
|
return env.redirect referer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -235,12 +231,8 @@ module Invidious::Routes::Playlists
|
||||||
page = env.params.query["page"]?.try &.to_i?
|
page = env.params.query["page"]?.try &.to_i?
|
||||||
page ||= 1
|
page ||= 1
|
||||||
|
|
||||||
begin
|
playlist = Invidious::Database::Playlists.select(id: plid)
|
||||||
playlist = Invidious::Database::Playlists.select(id: plid, raise_on_fail: true)
|
if !playlist || playlist.author != user.email
|
||||||
if !playlist || playlist.author != user.email
|
|
||||||
return env.redirect referer
|
|
||||||
end
|
|
||||||
rescue ex
|
|
||||||
return env.redirect referer
|
return env.redirect referer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue