Allow unlisted playlists to be viewed from /api/v1/playlists/

This commit is contained in:
Omar Roth 2019-10-16 08:21:26 -04:00
parent 57a80a3c10
commit bf48809b61
No known key found for this signature in database
GPG Key ID: B8254FB7EC3D37F2

View File

@ -4596,7 +4596,7 @@ end
end end
user = env.get?("user").try &.as(User) user = env.get?("user").try &.as(User)
if !playlist || !playlist.privacy.public? && playlist.author != user.try &.email if !playlist || playlist.privacy.private? && playlist.author != user.try &.email
env.response.status_code = 404 env.response.status_code = 404
error_message = {"error" => "Playlist does not exist."}.to_json error_message = {"error" => "Playlist does not exist."}.to_json
next error_message next error_message
@ -4888,7 +4888,7 @@ patch "/api/v1/auth/playlists/:plid" do |env|
plid = env.params.url["plid"] plid = env.params.url["plid"]
playlist = PG_DB.query_one?("SELECT * FROM playlists WHERE id = $1", plid, as: InvidiousPlaylist) playlist = PG_DB.query_one?("SELECT * FROM playlists WHERE id = $1", plid, as: InvidiousPlaylist)
if !playlist || playlist.author != user.email && !playlist.privacy.public? if !playlist || playlist.author != user.email && playlist.privacy.private?
env.response.status_code = 404 env.response.status_code = 404
error_message = {"error" => "Playlist does not exist."}.to_json error_message = {"error" => "Playlist does not exist."}.to_json
next error_message next error_message
@ -4923,7 +4923,7 @@ delete "/api/v1/auth/playlists/:plid" do |env|
plid = env.params.url["plid"] plid = env.params.url["plid"]
playlist = PG_DB.query_one?("SELECT * FROM playlists WHERE id = $1", plid, as: InvidiousPlaylist) playlist = PG_DB.query_one?("SELECT * FROM playlists WHERE id = $1", plid, as: InvidiousPlaylist)
if !playlist || playlist.author != user.email && !playlist.privacy.public? if !playlist || playlist.author != user.email && playlist.privacy.private?
env.response.status_code = 404 env.response.status_code = 404
error_message = {"error" => "Playlist does not exist."}.to_json error_message = {"error" => "Playlist does not exist."}.to_json
next error_message next error_message
@ -4950,7 +4950,7 @@ post "/api/v1/auth/playlists/:plid/videos" do |env|
plid = env.params.url["plid"] plid = env.params.url["plid"]
playlist = PG_DB.query_one?("SELECT * FROM playlists WHERE id = $1", plid, as: InvidiousPlaylist) playlist = PG_DB.query_one?("SELECT * FROM playlists WHERE id = $1", plid, as: InvidiousPlaylist)
if !playlist || playlist.author != user.email && !playlist.privacy.public? if !playlist || playlist.author != user.email && playlist.privacy.private?
env.response.status_code = 404 env.response.status_code = 404
error_message = {"error" => "Playlist does not exist."}.to_json error_message = {"error" => "Playlist does not exist."}.to_json
next error_message next error_message
@ -5016,7 +5016,7 @@ delete "/api/v1/auth/playlists/:plid/videos/:index" do |env|
index = env.params.url["index"].to_i64(16) index = env.params.url["index"].to_i64(16)
playlist = PG_DB.query_one?("SELECT * FROM playlists WHERE id = $1", plid, as: InvidiousPlaylist) playlist = PG_DB.query_one?("SELECT * FROM playlists WHERE id = $1", plid, as: InvidiousPlaylist)
if !playlist || playlist.author != user.email && !playlist.privacy.public? if !playlist || playlist.author != user.email && playlist.privacy.private?
env.response.status_code = 404 env.response.status_code = 404
error_message = {"error" => "Playlist does not exist."}.to_json error_message = {"error" => "Playlist does not exist."}.to_json
next error_message next error_message