aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/activity_pub/builder.ex
diff options
context:
space:
mode:
authorLain Soykaf <lain@soykaf.club>2021-01-28 09:33:30 +0100
committerLain Soykaf <lain@soykaf.club>2021-01-28 09:33:30 +0100
commitd18ba133b2db3d6af05cce191c5ea0c200b57346 (patch)
treeaac2e5fa108474fc8b2e369647075ab1a506b9b4 /lib/pleroma/web/activity_pub/builder.ex
parent633d0286b3cecc5140490b3a27e2732f98e012c5 (diff)
downloadpleroma-groups.tar.gz
Groups: Basic group validation.groups
Diffstat (limited to 'lib/pleroma/web/activity_pub/builder.ex')
-rw-r--r--lib/pleroma/web/activity_pub/builder.ex25
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