aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/pleroma/activity.ex15
-rw-r--r--test/web/mastodon_api/mastodon_api_controller_test.exs9
2 files changed, 20 insertions, 4 deletions
diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex
index 2d4e9da0c..56c51aef8 100644
--- a/lib/pleroma/activity.ex
+++ b/lib/pleroma/activity.ex
@@ -150,11 +150,18 @@ defmodule Pleroma.Activity do
)
end
+ @spec get_by_id(String.t()) :: Activity.t() | nil
def get_by_id(id) do
- Activity
- |> where([a], a.id == ^id)
- |> restrict_deactivated_users()
- |> Repo.one()
+ case Pleroma.FlakeId.is_flake_id?(id) do
+ true ->
+ Activity
+ |> where([a], a.id == ^id)
+ |> restrict_deactivated_users()
+ |> Repo.one()
+
+ _ ->
+ nil
+ end
end
def get_by_id_with_object(id) do
diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs
index 7b337044c..35c2236c8 100644
--- a/test/web/mastodon_api/mastodon_api_controller_test.exs
+++ b/test/web/mastodon_api/mastodon_api_controller_test.exs
@@ -2864,6 +2864,15 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
assert response == %{}
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
test "bookmarks" do