diff options
author | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2021-08-09 10:02:37 +0000 |
---|---|---|
committer | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2021-08-09 10:02:37 +0000 |
commit | 901204df2292419378a486a97fea9d3c70903a20 (patch) | |
tree | e7b2b68201819dce06079d4decfacaa4c8aa1043 /test/support | |
parent | 6384d7803520f633a66d1cb9f76e3540863f92fb (diff) | |
parent | 85d71d4f1d433a168eb136ad88b651b6c1d1a4fc (diff) | |
download | pleroma-901204df2292419378a486a97fea9d3c70903a20.tar.gz |
Merge branch 'poll-notification' into 'develop'
MastodonAPI: Support poll notification
See merge request pleroma/pleroma!3484
Diffstat (limited to 'test/support')
-rw-r--r-- | test/support/factory.ex | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/test/support/factory.ex b/test/support/factory.ex index f31f64a50..4a78425ce 100644 --- a/test/support/factory.ex +++ b/test/support/factory.ex @@ -213,6 +213,38 @@ defmodule Pleroma.Factory do } end + def question_factory(attrs \\ %{}) do + user = attrs[:user] || insert(:user) + + data = %{ + "id" => Pleroma.Web.ActivityPub.Utils.generate_object_id(), + "type" => "Question", + "actor" => user.ap_id, + "attributedTo" => user.ap_id, + "attachment" => [], + "to" => ["https://www.w3.org/ns/activitystreams#Public"], + "cc" => [user.follower_address], + "context" => Pleroma.Web.ActivityPub.Utils.generate_context_id(), + "closed" => DateTime.utc_now() |> DateTime.add(86_400) |> DateTime.to_iso8601(), + "oneOf" => [ + %{ + "type" => "Note", + "name" => "chocolate", + "replies" => %{"totalItems" => 0, "type" => "Collection"} + }, + %{ + "type" => "Note", + "name" => "vanilla", + "replies" => %{"totalItems" => 0, "type" => "Collection"} + } + ] + } + + %Pleroma.Object{ + data: merge_attributes(data, Map.get(attrs, :data, %{})) + } + end + def direct_note_activity_factory do dm = insert(:direct_note) @@ -428,6 +460,33 @@ defmodule Pleroma.Factory 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 oauth_app_factory do %Pleroma.Web.OAuth.App{ client_name: sequence(:client_name, &"Some client #{&1}"), |