94 lines
3 KiB
Elixir
94 lines
3 KiB
Elixir
defmodule Nulla.Fixtures.Data do
|
|
alias Nulla.KeyGen
|
|
alias Nulla.Models.User
|
|
alias Nulla.Models.Actor
|
|
alias Nulla.Models.Note
|
|
|
|
def create_data 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")
|
|
})
|
|
|
|
User.create_user(%{
|
|
id: actor.id,
|
|
email: "test@localhost",
|
|
password: "password",
|
|
privateKeyPem: privateKeyPem,
|
|
last_active_at: DateTime.utc_now()
|
|
})
|
|
|
|
Note.create_note(%{
|
|
actor_url: actor.url,
|
|
content: "Hello World from Nulla!",
|
|
language: "en",
|
|
actor_id: actor.id,
|
|
visibility: "public"
|
|
})
|
|
|
|
{publicKeyPem, privateKeyPem} = KeyGen.gen()
|
|
|
|
{:ok, actor} =
|
|
Actor.create_actor(%{
|
|
domain: "localhost",
|
|
ap_id: "http://localhost/users/test2",
|
|
type: "Person",
|
|
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: "http://localhost/@test2",
|
|
manuallyApprovesFollowers: false,
|
|
discoverable: true,
|
|
indexable: true,
|
|
published: DateTime.utc_now(),
|
|
memorial: false,
|
|
publicKey:
|
|
Jason.OrderedObject.new(
|
|
id: "http://localhost/users/test2#main-key",
|
|
owner: "http://localhost/users/test2",
|
|
publicKeyPem: publicKeyPem
|
|
),
|
|
endpoints: Jason.OrderedObject.new(sharedInbox: "http://localhost/inbox")
|
|
})
|
|
|
|
User.create_user(%{
|
|
id: actor.id,
|
|
email: "test2@localhost",
|
|
password: "password",
|
|
privateKeyPem: privateKeyPem,
|
|
last_active_at: DateTime.utc_now()
|
|
})
|
|
end
|
|
end
|