Fix several Fever API bugs

This commit is contained in:
Shadowfacts 2019-11-10 14:55:24 -05:00
parent 24643fa91a
commit fb6a441acd
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 4 additions and 6 deletions

View File

@ -50,7 +50,7 @@ defmodule FrenzyWeb.FeverController do
end
defp fever_response(user, params) do
%{api_version: 2, auth: 1}
%{api_version: 3, auth: 1}
|> mark(user, params)
|> unread_recently_read(user, params)
|> feeds(user, params)
@ -211,7 +211,7 @@ defmodule FrenzyWeb.FeverController do
{id, _} = id |> String.trim() |> Integer.parse()
item = Repo.get(Item, id)
if item.feed_id in feed_ids do
if not is_nil(item) and item.feed_id in feed_ids do
item
else
nil
@ -221,24 +221,22 @@ defmodule FrenzyWeb.FeverController do
Map.has_key?(params, "since_id") ->
since = Repo.get(Item, params["since_id"])
{since, _} = Integer.parse(since)
Repo.all(
from i in Item,
where: i.feed_id in ^feed_ids,
where: i.inserted_at > ^since,
where: i.inserted_at > ^since.inserted_at,
order_by: [asc: :id],
limit: 50
)
Map.has_key?(params, "max_id") ->
max = Repo.get(Item, params["max_id"])
{max, _} = Integer.parse(max)
Repo.all(
from i in Item,
where: i.feed_id in ^feed_ids,
where: i.inserted_at < ^max,
where: i.inserted_at < ^max.inserted_at,
order_by: [desc: :id],
limit: 50
)