This commit is contained in:
Mirai Kumiko 2025-06-29 14:59:33 +02:00
parent 748baff8f3
commit 1faafeee26
Signed by: miraikumiko
GPG key ID: 3F178B1B5E0CB278
11 changed files with 126 additions and 48 deletions

View file

@ -4,30 +4,24 @@ defmodule Nulla.Fixtures.Data do
alias Nulla.Models.Actor
alias Nulla.Models.Note
def create do
endpoint_config = Application.fetch_env!(:nulla, NullaWeb.Endpoint)
ip = endpoint_config[:http][:ip]
host = :inet_parse.ntoa(ip) |> to_string()
port = endpoint_config[:http][:port]
base_url = "http://#{host}:#{port}"
def create_data do
{publicKeyPem, privateKeyPem} = KeyGen.gen()
{:ok, actor} =
Actor.create_actor(%{
domain: "localhost",
ap_id: "#{base_url}/users/test",
ap_id: "http://localhost/users/test",
type: "Person",
following: "#{base_url}/users/test/following",
followers: "#{base_url}/users/test/followers",
inbox: "#{base_url}/users/test/inbox",
outbox: "#{base_url}/users/test/outbox",
featured: "#{base_url}/users/test/collections/featured",
featuredTags: "#{base_url}/users/test/collections/tags",
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: "#{base_url}/@test",
url: "http://localhost/@test",
manuallyApprovesFollowers: false,
discoverable: true,
indexable: true,
@ -35,11 +29,11 @@ defmodule Nulla.Fixtures.Data do
memorial: false,
publicKey:
Jason.OrderedObject.new(
id: "#{base_url}/users/test#main-key",
owner: "#{base_url}/users/test",
id: "http://localhost/users/test#main-key",
owner: "http://localhost/users/test",
publicKeyPem: publicKeyPem
),
endpoints: Jason.OrderedObject.new(sharedInbox: "#{base_url}/inbox")
endpoints: Jason.OrderedObject.new(sharedInbox: "http://localhost/inbox")
})
User.create_user(%{
@ -62,18 +56,18 @@ defmodule Nulla.Fixtures.Data do
{:ok, actor} =
Actor.create_actor(%{
domain: "localhost",
ap_id: "#{base_url}/users/test2",
ap_id: "http://localhost/users/test2",
type: "Person",
following: "#{base_url}/users/test2/following",
followers: "#{base_url}/users/test2/followers",
inbox: "#{base_url}/users/test2/inbox",
outbox: "#{base_url}/users/test2/outbox",
featured: "#{base_url}/users/test2/collections/featured",
featuredTags: "#{base_url}/users/test2/collections/tags",
following: "http://localhost/users/test2/following",
followers: "http://localhost/users/test2/followers",
inbox: "http://localhost/users/test2/inbox",
outbox: "http://localhost/users/test2/outbox",
featured: "http://localhost/users/test2/collections/featured",
featuredTags: "http://localhost/users/test2/collections/tags",
preferredUsername: "test2",
name: "Test",
summary: "Test User",
url: "#{base_url}/@test2",
url: "http://localhost/@test2",
manuallyApprovesFollowers: false,
discoverable: true,
indexable: true,
@ -81,11 +75,11 @@ defmodule Nulla.Fixtures.Data do
memorial: false,
publicKey:
Jason.OrderedObject.new(
id: "#{base_url}/users/test2#main-key",
owner: "#{base_url}/users/test2",
id: "http://localhost/users/test2#main-key",
owner: "http://localhost/users/test2",
publicKeyPem: publicKeyPem
),
endpoints: Jason.OrderedObject.new(sharedInbox: "#{base_url}/inbox")
endpoints: Jason.OrderedObject.new(sharedInbox: "http://localhost/inbox")
})
User.create_user(%{