projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[#3251] Fixed wrong test-env config setting for [Pleroma.Upload]. Refactoring. Added...
[akkoma]
/
test
/
support
/
builders
/
activity_builder.ex
diff --git
a/test/support/builders/activity_builder.ex
b/test/support/builders/activity_builder.ex
index b44afa896899c93e1496f40adcd74a7c39f79ed3..7c4950bfa08a6b9559f587daa3e7bc5a49b77b24 100644
(file)
--- a/
test/support/builders/activity_builder.ex
+++ b/
test/support/builders/activity_builder.ex
@@
-1,38
+1,49
@@
defmodule Pleroma.Builders.ActivityBuilder do
defmodule Pleroma.Builders.ActivityBuilder do
- alias Pleroma.Builders.UserBuilder
alias Pleroma.Web.ActivityPub.ActivityPub
def build(data \\ %{}, opts \\ %{}) do
alias Pleroma.Web.ActivityPub.ActivityPub
def build(data \\ %{}, opts \\ %{}) do
- user = opts[:user] || UserBuilder.build
+ user = opts[:user] || Pleroma.Factory.insert(:user)
+
activity = %{
activity = %{
- "id" =>
1
,
+ "id" =>
Pleroma.Web.ActivityPub.Utils.generate_object_id()
,
"actor" => user.ap_id,
"to" => ["https://www.w3.org/ns/activitystreams#Public"],
"actor" => user.ap_id,
"to" => ["https://www.w3.org/ns/activitystreams#Public"],
+ "type" => "Create",
"object" => %{
"type" => "Note",
"object" => %{
"type" => "Note",
- "content" => "test"
+ "content" => "test",
+ "to" => ["https://www.w3.org/ns/activitystreams#Public"]
}
}
}
}
+
Map.merge(activity, data)
end
def insert(data \\ %{}, opts \\ %{}) do
activity = build(data, opts)
Map.merge(activity, data)
end
def insert(data \\ %{}, opts \\ %{}) do
activity = build(data, opts)
- ActivityPub.insert(activity)
+
+ case ActivityPub.insert(activity) do
+ ok = {:ok, activity} ->
+ ActivityPub.notify_and_stream(activity)
+ ok
+
+ error ->
+ error
+ end
end
def insert_list(times, data \\ %{}, opts \\ %{}) do
end
def insert_list(times, data \\ %{}, opts \\ %{}) do
- Enum.map(1..times, fn
(n)
->
- {:ok, activity} = insert(
%{"id" => n}
)
+ Enum.map(1..times, fn
_n
->
+ {:ok, activity} = insert(
data, opts
)
activity
end)
end
def public_and_non_public do
activity
end)
end
def public_and_non_public do
- {:ok, user} = UserBuilder.insert
+ user = Pleroma.Factory.insert(:user)
public = build(%{"id" => 1}, %{user: user})
public = build(%{"id" => 1}, %{user: user})
- non_public = build(%{"id" => 2, "to" => []}, %{user: user})
+ non_public = build(%{"id" => 2, "to" => [
user.follower_address
]}, %{user: user})
{:ok, public} = ActivityPub.insert(public)
{:ok, non_public} = ActivityPub.insert(non_public)
{:ok, public} = ActivityPub.insert(public)
{:ok, non_public} = ActivityPub.insert(non_public)