removeing corresponding add activity
This commit is contained in:
parent
5ae9b05600
commit
8857242c95
4 changed files with 78 additions and 0 deletions
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
defmodule Pleroma.Factory do
|
||||
use ExMachina.Ecto, repo: Pleroma.Repo
|
||||
|
||||
require Pleroma.Constants
|
||||
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.User
|
||||
|
||||
|
|
@ -225,6 +228,45 @@ defmodule Pleroma.Factory do
|
|||
}
|
||||
end
|
||||
|
||||
def add_activity_factory(attrs \\ %{}) do
|
||||
featured_collection_activity(attrs, "Add")
|
||||
end
|
||||
|
||||
def remove_activity_factor(attrs \\ %{}) do
|
||||
featured_collection_activity(attrs, "Remove")
|
||||
end
|
||||
|
||||
defp featured_collection_activity(attrs, type) do
|
||||
user = attrs[:user] || insert(:user)
|
||||
note = attrs[:note] || insert(:note, user: user)
|
||||
|
||||
data_attrs =
|
||||
attrs
|
||||
|> Map.get(:data_attrs, %{})
|
||||
|> Map.put(:type, type)
|
||||
|
||||
attrs = Map.drop(attrs, [:user, :note, :data_attrs])
|
||||
|
||||
data =
|
||||
%{
|
||||
"id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id(),
|
||||
"target" => user.featured_address,
|
||||
"object" => note.data["object"],
|
||||
"actor" => note.data["actor"],
|
||||
"type" => "Add",
|
||||
"to" => [Pleroma.Constants.as_public()],
|
||||
"cc" => [user.follower_address]
|
||||
}
|
||||
|> Map.merge(data_attrs)
|
||||
|
||||
%Pleroma.Activity{
|
||||
data: data,
|
||||
actor: data["actor"],
|
||||
recipients: data["to"]
|
||||
}
|
||||
|> Map.merge(attrs)
|
||||
end
|
||||
|
||||
def note_activity_factory(attrs \\ %{}) do
|
||||
user = attrs[:user] || insert(:user)
|
||||
note = attrs[:note] || insert(:note, user: user)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue