Refresh account for subscription feed and manager

This commit is contained in:
Omar Roth 2018-07-17 08:19:45 -05:00
parent cecb93f832
commit 7119395045
1 changed files with 15 additions and 0 deletions

View File

@ -750,6 +750,13 @@ get "/feed/subscriptions" do |env|
if user
user = user.as(User)
# Refresh account
headers = HTTP::Headers.new
headers["Cookie"] = env.request.headers["Cookie"]
client = make_client(YT_URL)
user = get_user(user.id, client, headers, PG_DB)
max_results = user.preferences.max_results
max_results ||= env.params.query["maxResults"]?.try &.to_i
max_results ||= 40
@ -848,6 +855,14 @@ get "/subscription_manager" do |env|
end
user = user.as(User)
# Refresh account
headers = HTTP::Headers.new
headers["Cookie"] = env.request.headers["Cookie"]
client = make_client(YT_URL)
user = get_user(user.id, client, headers, PG_DB)
subscriptions = user.subscriptions
subscriptions ||= [] of String