diff options
Diffstat (limited to 'lib/pleroma/web/activity_pub/builder.ex')
-rw-r--r-- | lib/pleroma/web/activity_pub/builder.ex | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/pleroma/web/activity_pub/builder.ex b/lib/pleroma/web/activity_pub/builder.ex index f56bfc600..08f017a51 100644 --- a/lib/pleroma/web/activity_pub/builder.ex +++ b/lib/pleroma/web/activity_pub/builder.ex @@ -12,6 +12,7 @@ defmodule Pleroma.Web.ActivityPub.Builder do alias Pleroma.Emoji alias Pleroma.Object alias Pleroma.User + alias Pleroma.Web alias Pleroma.Web.ActivityPub.Relay alias Pleroma.Web.ActivityPub.Utils alias Pleroma.Web.ActivityPub.Visibility @@ -105,6 +106,30 @@ defmodule Pleroma.Web.ActivityPub.Builder do }, []} end + def group(owner, name \\ nil, description \\ nil) do + id = Ecto.UUID.generate() + ap_id = "#{Web.base_url()}/groups/#{id}" + + {:ok, + %{ + "id" => ap_id, + "type" => "Group", + "name" => name, + "summary" => description, + "following" => "#{ap_id}/following", + "followers" => "#{ap_id}/followers", + "members" => "#{ap_id}/members", + # attributedTo? owner? admin? + "attributedTo" => owner.ap_id + }, []} + end + + def create_group(owner, params \\ %{}) do + with {:ok, group, _} <- group(owner, params[:name], params[:description]) do + create(owner, group, []) + end + end + def create(actor, object, recipients) do context = if is_map(object) do |