activitypub: use Object.normalize() instead of Object.get_by_ap_id() directly.

This commit is contained in:
William Pitcock 2018-06-18 21:01:33 +00:00
parent fb04fecfb4
commit 15d624e077
2 changed files with 4 additions and 4 deletions

View File

@ -670,7 +670,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
recv_timeout: 20000 recv_timeout: 20000
), ),
{:ok, data} <- Jason.decode(body), {:ok, data} <- Jason.decode(body),
nil <- Object.get_by_ap_id(data["id"]), nil <- Object.normalize(data),
params <- %{ params <- %{
"type" => "Create", "type" => "Create",
"to" => data["to"], "to" => data["to"],
@ -679,7 +679,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
"object" => data "object" => data
}, },
{:ok, activity} <- Transmogrifier.handle_incoming(params) do {:ok, activity} <- Transmogrifier.handle_incoming(params) do
{:ok, Object.get_by_ap_id(activity.data["object"]["id"])} {:ok, Object.normalize(activity.data["object"])}
else else
object = %Object{} -> object = %Object{} ->
{:ok, object} {:ok, object}
@ -688,7 +688,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
Logger.info("Couldn't get object via AP, trying out OStatus fetching...") Logger.info("Couldn't get object via AP, trying out OStatus fetching...")
case OStatus.fetch_activity_from_url(id) do case OStatus.fetch_activity_from_url(id) do
{:ok, [activity | _]} -> {:ok, Object.get_by_ap_id(activity.data["object"]["id"])} {:ok, [activity | _]} -> {:ok, Object.normalize(activity.data["object"])}
e -> e e -> e
end end
end end

View File

@ -412,7 +412,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
def handle_incoming(_), do: :error def handle_incoming(_), do: :error
def get_obj_helper(id) do def get_obj_helper(id) do
if object = Object.get_by_ap_id(id), do: {:ok, object}, else: nil if object = Object.normalize(id), do: {:ok, object}, else: nil
end end
def set_reply_to_uri(%{"inReplyTo" => inReplyTo} = object) do def set_reply_to_uri(%{"inReplyTo" => inReplyTo} = object) do