Compare commits
No commits in common. "c288831bb26108f27d3766e1faae7c9bcec96d80" and "b475f86313753f266b7221c26a22b8a3395ed1f8" have entirely different histories.
c288831bb2
...
b475f86313
4 changed files with 2 additions and 94 deletions
|
@ -90,8 +90,6 @@ defmodule Nulla.Models.Actor do
|
||||||
:publicKey,
|
:publicKey,
|
||||||
:endpoints
|
:endpoints
|
||||||
])
|
])
|
||||||
|> unique_constraint([:preferredUsername, :domain])
|
|
||||||
|> unique_constraint(:ap_id)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_actor(attrs) when is_map(attrs) do
|
def create_actor(attrs) when is_map(attrs) do
|
||||||
|
|
|
@ -48,8 +48,7 @@ defmodule Nulla.Models.Note do
|
||||||
from(n in __MODULE__,
|
from(n in __MODULE__,
|
||||||
where: n.actor_id == ^actor_id,
|
where: n.actor_id == ^actor_id,
|
||||||
order_by: [desc: n.inserted_at],
|
order_by: [desc: n.inserted_at],
|
||||||
limit: ^limit,
|
limit: ^limit
|
||||||
preload: [:actor, :media_attachments]
|
|
||||||
)
|
)
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
end
|
end
|
||||||
|
@ -58,8 +57,7 @@ defmodule Nulla.Models.Note do
|
||||||
from(n in __MODULE__,
|
from(n in __MODULE__,
|
||||||
where: n.actor_id == ^actor_id and n.id < ^max_id,
|
where: n.actor_id == ^actor_id and n.id < ^max_id,
|
||||||
order_by: [desc: n.inserted_at],
|
order_by: [desc: n.inserted_at],
|
||||||
limit: ^limit,
|
limit: ^limit
|
||||||
preload: [:actor, :media_attachments]
|
|
||||||
)
|
)
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,8 +31,5 @@ defmodule Nulla.Repo.Migrations.CreateActors do
|
||||||
add :vcard_bday, :date
|
add :vcard_bday, :date
|
||||||
add :vcard_Address, :string
|
add :vcard_Address, :string
|
||||||
end
|
end
|
||||||
|
|
||||||
create unique_index(:actors, [:preferredUsername, :domain])
|
|
||||||
create unique_index(:actors, [:ap_id])
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,85 +0,0 @@
|
||||||
defmodule NullaWeb.OutboxControllerTest do
|
|
||||||
use NullaWeb.ConnCase
|
|
||||||
alias Nulla.KeyGen
|
|
||||||
alias Nulla.Snowflake
|
|
||||||
alias Nulla.Models.Actor
|
|
||||||
alias Nulla.Models.Note
|
|
||||||
|
|
||||||
setup do
|
|
||||||
{publicKeyPem, _privateKeyPem} = KeyGen.gen()
|
|
||||||
|
|
||||||
{:ok, actor} =
|
|
||||||
Actor.create_actor(%{
|
|
||||||
domain: "localhost",
|
|
||||||
ap_id: "http://localhost/users/test",
|
|
||||||
type: "Person",
|
|
||||||
following: "http://localhost/users/test/following",
|
|
||||||
followers: "http://localhost/users/test/followers",
|
|
||||||
inbox: "http://localhost/users/test/inbox",
|
|
||||||
outbox: "http://localhost/users/test/outbox",
|
|
||||||
featured: "http://localhost/users/test/collections/featured",
|
|
||||||
featuredTags: "http://localhost/users/test/collections/tags",
|
|
||||||
preferredUsername: "test",
|
|
||||||
name: "Test",
|
|
||||||
summary: "Test User",
|
|
||||||
url: "http://localhost/@test",
|
|
||||||
manuallyApprovesFollowers: false,
|
|
||||||
discoverable: true,
|
|
||||||
indexable: true,
|
|
||||||
published: DateTime.utc_now(),
|
|
||||||
memorial: false,
|
|
||||||
publicKey:
|
|
||||||
Jason.OrderedObject.new(
|
|
||||||
id: "http://localhost/users/test#main-key",
|
|
||||||
owner: "http://localhost/users/test",
|
|
||||||
publicKeyPem: publicKeyPem
|
|
||||||
),
|
|
||||||
endpoints: Jason.OrderedObject.new(sharedInbox: "http://localhost/inbox")
|
|
||||||
})
|
|
||||||
|
|
||||||
note_id = Snowflake.next_id()
|
|
||||||
|
|
||||||
{:ok, _note} =
|
|
||||||
Note.create_note(%{
|
|
||||||
url: "#{actor.url}/#{note_id}",
|
|
||||||
content: "Hello World from Nulla!",
|
|
||||||
language: "en",
|
|
||||||
actor_id: actor.id
|
|
||||||
})
|
|
||||||
|
|
||||||
:ok
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "GET /users/username/outbox" do
|
|
||||||
test "returns ActivityPub JSON of outbox", %{conn: conn} do
|
|
||||||
conn =
|
|
||||||
conn
|
|
||||||
|> get(~p"/users/test/outbox")
|
|
||||||
|
|
||||||
assert response = json_response(conn, 200)
|
|
||||||
|
|
||||||
assert is_binary(response["@context"])
|
|
||||||
assert response["id"] == "http://localhost/users/test/outbox"
|
|
||||||
assert response["type"] == "OrderedCollection"
|
|
||||||
assert response["totalItems"] == 1
|
|
||||||
assert response["first"] == "http://localhost/users/test/outbox?page=true"
|
|
||||||
assert response["last"] == "http://localhost/users/test/outbox?min_id=0&page=true"
|
|
||||||
end
|
|
||||||
|
|
||||||
test "returns ActivityPub JSON of outbox with params", %{conn: conn} do
|
|
||||||
conn =
|
|
||||||
conn
|
|
||||||
|> get(~p"/users/test/outbox?page=true")
|
|
||||||
|
|
||||||
assert response = json_response(conn, 200)
|
|
||||||
|
|
||||||
assert is_list(response["@context"])
|
|
||||||
assert response["id"] == "http://localhost/users/test/outbox?page=true"
|
|
||||||
assert response["type"] == "OrderedCollectionPage"
|
|
||||||
assert is_binary(response["next"])
|
|
||||||
assert is_binary(response["prev"])
|
|
||||||
assert response["partOf"] == "http://localhost/users/test/outbox"
|
|
||||||
assert Enum.any?(response["orderedItems"])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Add table
Add a link
Reference in a new issue