Basic Room creation.

This commit is contained in:
lain 2018-10-10 15:21:29 +02:00 committed by William Pitcock
parent c1b42e3dae
commit 75f8cd195c
2 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,14 @@
defmodule Pleroma.Web.ActivityPub.Chat.Room do
alias Pleroma.Web.ActivityPub.Actor
def build(name) do
base_url = Pleroma.Web.Endpoint.url()
base = "#{base_url}/chat/rooms/#{name}"
with {:ok, actor} <- Actor.build(base) do
room = actor
|> Map.put("name", name)
|> Map.put("members", [])
{:ok, room}
end
end
end

View File

@ -0,0 +1,12 @@
defmodule Pleroma.Web.ActivityPub.Chat.RoomTest do
use Pleroma.DataCase
alias Pleroma.Web.ActivityPub.Chat.Room
test "builds a local room" do
{:ok, room} = Room.build("chatroom")
assert room["id"] =~ "/chat/rooms/chatroom"
assert room["name"] == "chatroom"
assert room["members"] == []
assert room["inbox"]
end
end