fix Activity.get_by_id
This commit is contained in:
parent
58b17196fa
commit
d8a178274b
2 changed files with 20 additions and 4 deletions
|
@ -150,11 +150,18 @@ defmodule Pleroma.Activity do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@spec get_by_id(String.t()) :: Activity.t() | nil
|
||||||
def get_by_id(id) do
|
def get_by_id(id) do
|
||||||
Activity
|
case Pleroma.FlakeId.is_flake_id?(id) do
|
||||||
|> where([a], a.id == ^id)
|
true ->
|
||||||
|> restrict_deactivated_users()
|
Activity
|
||||||
|> Repo.one()
|
|> where([a], a.id == ^id)
|
||||||
|
|> restrict_deactivated_users()
|
||||||
|
|> Repo.one()
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_by_id_with_object(id) do
|
def get_by_id_with_object(id) do
|
||||||
|
|
|
@ -2864,6 +2864,15 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
||||||
|
|
||||||
assert response == %{}
|
assert response == %{}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "returns empty object when id isn't FlakeID", %{conn: conn} do
|
||||||
|
response =
|
||||||
|
conn
|
||||||
|
|> get("/api/v1/statuses/3ebbadd1-eb14-4e20-8118/card")
|
||||||
|
|> json_response(200)
|
||||||
|
|
||||||
|
assert response == %{}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "bookmarks" do
|
test "bookmarks" do
|
||||||
|
|
Loading…
Reference in a new issue