1 defmodule Pleroma.Factory do
2 use ExMachina.Ecto, repo: Pleroma.Repo
6 name: sequence(:name, &"Test ใในใ User #{&1}"),
7 email: sequence(:email, &"user#{&1}@example.com"),
8 nickname: sequence(:nickname, &"nick#{&1}"),
9 password_hash: Comeonin.Pbkdf2.hashpwsalt("test"),
10 bio: sequence(:bio, &"Tester Number #{&1}"),
12 %{ user | ap_id: Pleroma.User.ap_id(user) }
16 text = sequence(:text, &"This is note #{&1}")
22 "id" => Pleroma.Web.ActivityPub.ActivityPub.generate_object_id,
23 "actor" => user.ap_id,
24 "to" => ["https://www.w3.org/ns/activitystreams#Public"],
25 "published_at" => DateTime.utc_now() |> DateTime.to_iso8601,
36 def note_activity_factory do
39 "id" => Pleroma.Web.ActivityPub.ActivityPub.generate_activity_id,
41 "actor" => note.data["actor"],
42 "to" => note.data["to"],
43 "object" => note.data,
44 "published_at" => DateTime.utc_now() |> DateTime.to_iso8601,
45 "context" => note.data["context"]
53 def like_activity_factory do
54 note_activity = insert(:note_activity)
58 "id" => Pleroma.Web.ActivityPub.ActivityPub.generate_activity_id,
59 "actor" => user.ap_id,
61 "object" => note_activity.data["object"]["id"],
62 "published_at" => DateTime.utc_now() |> DateTime.to_iso8601
70 def follow_activity_factory do
71 follower = insert(:user)
72 followed = insert(:user)
75 "id" => Pleroma.Web.ActivityPub.ActivityPub.generate_activity_id,
76 "actor" => follower.ap_id,
78 "object" => followed.ap_id,
79 "published_at" => DateTime.utc_now() |> DateTime.to_iso8601
87 def websub_subscription_factory do
88 %Pleroma.Web.Websub.WebsubServerSubscription{
89 topic: "http://example.org",
90 callback: "http://example/org/callback",
91 secret: "here's a secret",
92 valid_until: NaiveDateTime.add(NaiveDateTime.utc_now, 100),
97 def websub_client_subscription_factory do
98 %Pleroma.Web.Websub.WebsubClientSubscription{
99 topic: "http://example.org",
100 secret: "here's a secret",