mirror of
https://framagit.org/framasoft/mobilizon.git
synced 2024-12-21 23:44:30 +00:00
Fix checking origin from a tombstone
When comparing an activity with their origin, only compare the ID directly, as Tombstones don't have actors anymore Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
cb148e29d7
commit
6f9db37ca3
3 changed files with 13 additions and 1 deletions
|
@ -142,7 +142,7 @@ defmodule Mobilizon.Federation.ActivityPub.Fetcher do
|
|||
true
|
||||
else
|
||||
Sentry.capture_message("Object origin check failed", extra: %{url: url, data: data})
|
||||
Logger.debug("Object origin check failed")
|
||||
Logger.debug("Object origin check failed between #{inspect(url)} and #{inspect(data)}")
|
||||
false
|
||||
end
|
||||
end
|
||||
|
|
|
@ -239,6 +239,8 @@ defmodule Mobilizon.Federation.ActivityPub.Utils do
|
|||
|
||||
Takes the actor or attributedTo attributes (considers only the first elem if they're an array)
|
||||
"""
|
||||
def origin_check?(id, %{"type" => "Tombstone", "id" => tombstone_id}), do: id == tombstone_id
|
||||
|
||||
def origin_check?(id, %{"actor" => actor, "attributedTo" => _attributed_to} = params)
|
||||
when not is_nil(actor) and actor != "" do
|
||||
params = Map.delete(params, "attributedTo")
|
||||
|
|
|
@ -5,6 +5,7 @@ defmodule Mobilizon.Federation.ActivityPub.UtilsTest do
|
|||
|
||||
import Mobilizon.Factory
|
||||
|
||||
alias Mobilizon.Federation.ActivityPub.Utils
|
||||
alias Mobilizon.Federation.ActivityStream.Converter
|
||||
|
||||
alias Mobilizon.Web.Endpoint
|
||||
|
@ -51,4 +52,13 @@ defmodule Mobilizon.Federation.ActivityPub.UtilsTest do
|
|||
assert comment_data["inReplyTo"] == comment.url
|
||||
end
|
||||
end
|
||||
|
||||
describe "origin_check?" do
|
||||
test "origin_check? with a tombstone" do
|
||||
assert Utils.origin_check?("http://an_uri", %{
|
||||
"type" => "Tombstone",
|
||||
"id" => "http://an_uri"
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue