1 defmodule Pleroma.Builders.ActivityBuilder do
2 alias Pleroma.Builders.UserBuilder
3 alias Pleroma.Web.ActivityPub.ActivityPub
5 def build(data \\ %{}, opts \\ %{}) do
6 user = opts[:user] || UserBuilder.build
10 "to" => ["https://www.w3.org/ns/activitystreams#Public"],
16 Map.merge(activity, data)
19 def insert(data \\ %{}, opts \\ %{}) do
20 activity = build(data, opts)
21 ActivityPub.insert(activity)
24 def insert_list(times, data \\ %{}, opts \\ %{}) do
25 Enum.map(1..times, fn (n) ->
26 {:ok, activity} = insert(%{"id" => n})
31 def public_and_non_public do
32 {:ok, user} = UserBuilder.insert
34 public = build(%{"id" => 1}, %{user: user})
35 non_public = build(%{"id" => 2, "to" => []}, %{user: user})
37 {:ok, public} = ActivityPub.insert(public)
38 {:ok, non_public} = ActivityPub.insert(non_public)
42 non_public: non_public,