re-add question_activity_factory

This commit is contained in:
FloatingGhost 2022-12-01 13:27:09 +00:00
parent 0dc333fdb0
commit 7f7669b3db

View file

@ -494,6 +494,33 @@ def report_activity_factory(attrs \\ %{}) do
}
end
def question_activity_factory(attrs \\ %{}) do
user = attrs[:user] || insert(:user)
question = attrs[:question] || insert(:question, user: user)
data_attrs = attrs[:data_attrs] || %{}
attrs = Map.drop(attrs, [:user, :question, :data_attrs])
data =
%{
"id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id(),
"type" => "Create",
"actor" => question.data["actor"],
"to" => question.data["to"],
"object" => question.data["id"],
"published" => DateTime.utc_now() |> DateTime.to_iso8601(),
"context" => question.data["context"]
}
|> Map.merge(data_attrs)
%Pleroma.Activity{
data: data,
actor: data["actor"],
recipients: data["to"]
}
|> Map.merge(attrs)
end
def delete_activity_factory(attrs \\ %{}) do
user = attrs[:user] || insert(:user)
note_activity = attrs[:note_activity] || insert(:note_activity, user: user)