Use optional query for watch page

このコミットが含まれているのは:
Omar Roth 2018-04-03 17:06:50 -05:00
コミット 10c1cfa4b5
1個のファイルの変更3行の追加7行の削除

ファイルの表示

@ -217,17 +217,13 @@ get "/watch" do |env|
authorized = env.get? "authorized"
if authorized
headers = HTTP::Headers.new
headers["Cookie"] = env.request.headers["Cookie"]
sid = env.get("sid").as(String)
user = get_user(sid, client, headers, PG_DB)
subscriptions = user.subscriptions
else
subscriptions = [] of String
subscriptions = PG_DB.query_one?("SELECT subscriptions FROM users WHERE id = $1", sid, as: Array(String))
end
subscriptions = [] of String
begin
video = get_video(id, client, PG_DB)
rescue ex