Merge branch 'fix/activity-expiration-policy' into 'develop'
Fix ActivityExpirationPolicy Closes #2019 See merge request pleroma/pleroma!2847
This commit is contained in:
commit
917aa090f0
2 changed files with 9 additions and 2 deletions
|
@ -21,8 +21,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.ActivityExpirationPolicy do
|
||||||
@impl true
|
@impl true
|
||||||
def describe, do: {:ok, %{}}
|
def describe, do: {:ok, %{}}
|
||||||
|
|
||||||
defp local?(%{"id" => id}) do
|
defp local?(%{"actor" => actor}) do
|
||||||
String.starts_with?(id, Pleroma.Web.Endpoint.url())
|
String.starts_with?(actor, Pleroma.Web.Endpoint.url())
|
||||||
end
|
end
|
||||||
|
|
||||||
defp note?(activity) do
|
defp note?(activity) do
|
||||||
|
|
|
@ -7,11 +7,13 @@ defmodule Pleroma.Web.ActivityPub.MRF.ActivityExpirationPolicyTest do
|
||||||
alias Pleroma.Web.ActivityPub.MRF.ActivityExpirationPolicy
|
alias Pleroma.Web.ActivityPub.MRF.ActivityExpirationPolicy
|
||||||
|
|
||||||
@id Pleroma.Web.Endpoint.url() <> "/activities/cofe"
|
@id Pleroma.Web.Endpoint.url() <> "/activities/cofe"
|
||||||
|
@local_actor Pleroma.Web.Endpoint.url() <> "/users/cofe"
|
||||||
|
|
||||||
test "adds `expires_at` property" do
|
test "adds `expires_at` property" do
|
||||||
assert {:ok, %{"type" => "Create", "expires_at" => expires_at}} =
|
assert {:ok, %{"type" => "Create", "expires_at" => expires_at}} =
|
||||||
ActivityExpirationPolicy.filter(%{
|
ActivityExpirationPolicy.filter(%{
|
||||||
"id" => @id,
|
"id" => @id,
|
||||||
|
"actor" => @local_actor,
|
||||||
"type" => "Create",
|
"type" => "Create",
|
||||||
"object" => %{"type" => "Note"}
|
"object" => %{"type" => "Note"}
|
||||||
})
|
})
|
||||||
|
@ -25,6 +27,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.ActivityExpirationPolicyTest do
|
||||||
assert {:ok, %{"type" => "Create", "expires_at" => ^expires_at}} =
|
assert {:ok, %{"type" => "Create", "expires_at" => ^expires_at}} =
|
||||||
ActivityExpirationPolicy.filter(%{
|
ActivityExpirationPolicy.filter(%{
|
||||||
"id" => @id,
|
"id" => @id,
|
||||||
|
"actor" => @local_actor,
|
||||||
"type" => "Create",
|
"type" => "Create",
|
||||||
"expires_at" => expires_at,
|
"expires_at" => expires_at,
|
||||||
"object" => %{"type" => "Note"}
|
"object" => %{"type" => "Note"}
|
||||||
|
@ -37,6 +40,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.ActivityExpirationPolicyTest do
|
||||||
assert {:ok, %{"type" => "Create", "expires_at" => expires_at}} =
|
assert {:ok, %{"type" => "Create", "expires_at" => expires_at}} =
|
||||||
ActivityExpirationPolicy.filter(%{
|
ActivityExpirationPolicy.filter(%{
|
||||||
"id" => @id,
|
"id" => @id,
|
||||||
|
"actor" => @local_actor,
|
||||||
"type" => "Create",
|
"type" => "Create",
|
||||||
"expires_at" => too_distant_future,
|
"expires_at" => too_distant_future,
|
||||||
"object" => %{"type" => "Note"}
|
"object" => %{"type" => "Note"}
|
||||||
|
@ -49,6 +53,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.ActivityExpirationPolicyTest do
|
||||||
assert {:ok, activity} =
|
assert {:ok, activity} =
|
||||||
ActivityExpirationPolicy.filter(%{
|
ActivityExpirationPolicy.filter(%{
|
||||||
"id" => "https://example.com/123",
|
"id" => "https://example.com/123",
|
||||||
|
"actor" => "https://example.com/users/cofe",
|
||||||
"type" => "Create",
|
"type" => "Create",
|
||||||
"object" => %{"type" => "Note"}
|
"object" => %{"type" => "Note"}
|
||||||
})
|
})
|
||||||
|
@ -60,6 +65,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.ActivityExpirationPolicyTest do
|
||||||
assert {:ok, activity} =
|
assert {:ok, activity} =
|
||||||
ActivityExpirationPolicy.filter(%{
|
ActivityExpirationPolicy.filter(%{
|
||||||
"id" => "https://example.com/123",
|
"id" => "https://example.com/123",
|
||||||
|
"actor" => "https://example.com/users/cofe",
|
||||||
"type" => "Follow"
|
"type" => "Follow"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -68,6 +74,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.ActivityExpirationPolicyTest do
|
||||||
assert {:ok, activity} =
|
assert {:ok, activity} =
|
||||||
ActivityExpirationPolicy.filter(%{
|
ActivityExpirationPolicy.filter(%{
|
||||||
"id" => "https://example.com/123",
|
"id" => "https://example.com/123",
|
||||||
|
"actor" => "https://example.com/users/cofe",
|
||||||
"type" => "Create",
|
"type" => "Create",
|
||||||
"object" => %{"type" => "Cofe"}
|
"object" => %{"type" => "Cofe"}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue