Basic Room creation.
This commit is contained in:
parent
c1b42e3dae
commit
75f8cd195c
|
@ -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
|
|
@ -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
|
Loading…
Reference in New Issue