Fix several Fever API bugs
This commit is contained in:
parent
24643fa91a
commit
fb6a441acd
|
@ -50,7 +50,7 @@ defmodule FrenzyWeb.FeverController do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp fever_response(user, params) do
|
defp fever_response(user, params) do
|
||||||
%{api_version: 2, auth: 1}
|
%{api_version: 3, auth: 1}
|
||||||
|> mark(user, params)
|
|> mark(user, params)
|
||||||
|> unread_recently_read(user, params)
|
|> unread_recently_read(user, params)
|
||||||
|> feeds(user, params)
|
|> feeds(user, params)
|
||||||
|
@ -211,7 +211,7 @@ defmodule FrenzyWeb.FeverController do
|
||||||
{id, _} = id |> String.trim() |> Integer.parse()
|
{id, _} = id |> String.trim() |> Integer.parse()
|
||||||
item = Repo.get(Item, id)
|
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
|
item
|
||||||
else
|
else
|
||||||
nil
|
nil
|
||||||
|
@ -221,24 +221,22 @@ defmodule FrenzyWeb.FeverController do
|
||||||
|
|
||||||
Map.has_key?(params, "since_id") ->
|
Map.has_key?(params, "since_id") ->
|
||||||
since = Repo.get(Item, params["since_id"])
|
since = Repo.get(Item, params["since_id"])
|
||||||
{since, _} = Integer.parse(since)
|
|
||||||
|
|
||||||
Repo.all(
|
Repo.all(
|
||||||
from i in Item,
|
from i in Item,
|
||||||
where: i.feed_id in ^feed_ids,
|
where: i.feed_id in ^feed_ids,
|
||||||
where: i.inserted_at > ^since,
|
where: i.inserted_at > ^since.inserted_at,
|
||||||
order_by: [asc: :id],
|
order_by: [asc: :id],
|
||||||
limit: 50
|
limit: 50
|
||||||
)
|
)
|
||||||
|
|
||||||
Map.has_key?(params, "max_id") ->
|
Map.has_key?(params, "max_id") ->
|
||||||
max = Repo.get(Item, params["max_id"])
|
max = Repo.get(Item, params["max_id"])
|
||||||
{max, _} = Integer.parse(max)
|
|
||||||
|
|
||||||
Repo.all(
|
Repo.all(
|
||||||
from i in Item,
|
from i in Item,
|
||||||
where: i.feed_id in ^feed_ids,
|
where: i.feed_id in ^feed_ids,
|
||||||
where: i.inserted_at < ^max,
|
where: i.inserted_at < ^max.inserted_at,
|
||||||
order_by: [desc: :id],
|
order_by: [desc: :id],
|
||||||
limit: 50
|
limit: 50
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue