Ignore when trying to import non-statuses

This commit is contained in:
tusooa 2022-11-07 12:24:41 -05:00
parent 7379f1417b
commit 39cf8fae08
No known key found for this signature in database
GPG key ID: 7B467EDE43A08224
2 changed files with 26 additions and 1 deletions

View file

@ -49,11 +49,13 @@ def import_object(
end
end
def import_object(_, _, _), do: {:ok, nil}
def import_activity(%{"type" => "Create", "object" => object} = _activity, %User{} = user, opts) do
import_object(object, user, opts)
end
def import_activity(_, _, _), do: nil
def import_activity(_, _, _), do: {:ok, nil}
def import_one(%{"type" => type} = object, %User{} = user, opts \\ []) do
if type in Pleroma.Constants.status_types() do

View file

@ -108,5 +108,28 @@ test "it keeps public and unlisted posts unlisted with keep_unlisted option" do
verify_with_visibility.("private", false)
verify_with_visibility.("direct", false)
end
test "ignores on non-Create" do
importing_user = insert(:user)
assert {:ok, nil} =
Importer.import_one(%{"type" => "Announce", "object" => %{}}, importing_user)
end
test "ignores on non-status types" do
importing_user = insert(:user)
assert {:ok, nil} =
Importer.import_one(
%{"type" => "Create", "object" => %{"type" => "ChatMessage"}},
importing_user
)
assert {:ok, nil} =
Importer.import_one(
%{"type" => "Create", "object" => %{"type" => "Answer"}},
importing_user
)
end
end
end