diff options
author | Alex Gleason <alex@alexgleason.me> | 2021-07-17 20:35:35 -0500 |
---|---|---|
committer | Alex Gleason <alex@alexgleason.me> | 2021-07-17 22:19:38 -0500 |
commit | 0114754db2d9dde25b31729644f898f20121de27 (patch) | |
tree | 72c5f8bf0890ebbcf2f7876db99e1308b28689f9 /test/support | |
parent | b221d77a6da07c684bdbc63ddf4500e0d7ffeae8 (diff) | |
download | pleroma-0114754db2d9dde25b31729644f898f20121de27.tar.gz |
MastodonAPI: Support poll notification
Diffstat (limited to 'test/support')
-rw-r--r-- | test/support/factory.ex | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/support/factory.ex b/test/support/factory.ex index af4fff45b..e87e54e7b 100644 --- a/test/support/factory.ex +++ b/test/support/factory.ex @@ -201,6 +201,36 @@ 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, + "attachment" => [], + "to" => ["https://www.w3.org/ns/activitystreams#Public"], + "cc" => [user.follower_address], + "context" => Pleroma.Web.ActivityPub.Utils.generate_context_id(), + "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) @@ -350,6 +380,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}"), |