Ignore when trying to import non-statuses
This commit is contained in:
parent
7379f1417b
commit
39cf8fae08
2 changed files with 26 additions and 1 deletions
|
@ -49,11 +49,13 @@ def import_object(
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def import_object(_, _, _), do: {:ok, nil}
|
||||||
|
|
||||||
def import_activity(%{"type" => "Create", "object" => object} = _activity, %User{} = user, opts) do
|
def import_activity(%{"type" => "Create", "object" => object} = _activity, %User{} = user, opts) do
|
||||||
import_object(object, user, opts)
|
import_object(object, user, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
def import_activity(_, _, _), do: nil
|
def import_activity(_, _, _), do: {:ok, nil}
|
||||||
|
|
||||||
def import_one(%{"type" => type} = object, %User{} = user, opts \\ []) do
|
def import_one(%{"type" => type} = object, %User{} = user, opts \\ []) do
|
||||||
if type in Pleroma.Constants.status_types() do
|
if type in Pleroma.Constants.status_types() do
|
||||||
|
|
|
@ -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.("private", false)
|
||||||
verify_with_visibility.("direct", false)
|
verify_with_visibility.("direct", false)
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue