mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-11-20 00:20:59 +00:00
Transmogrifier: Handle Update
with the pipeline.
This commit is contained in:
parent
31a4d42ce0
commit
9438f83f83
1 changed files with 5 additions and 28 deletions
|
@ -684,35 +684,12 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_incoming(
|
def handle_incoming(
|
||||||
%{"type" => "Update", "object" => %{"type" => object_type} = object, "actor" => actor_id} =
|
%{"type" => "Update"} = data,
|
||||||
data,
|
|
||||||
_options
|
_options
|
||||||
)
|
) do
|
||||||
when object_type in [
|
with {:ok, %User{}} <- ObjectValidator.fetch_actor(data),
|
||||||
"Person",
|
{:ok, activity, _} <- Pipeline.common_pipeline(data, local: false) do
|
||||||
"Application",
|
{:ok, activity}
|
||||||
"Service",
|
|
||||||
"Organization"
|
|
||||||
] do
|
|
||||||
with %User{ap_id: ^actor_id} = actor <- User.get_cached_by_ap_id(object["id"]) do
|
|
||||||
{:ok, new_user_data} = ActivityPub.user_data_from_user_object(object)
|
|
||||||
|
|
||||||
actor
|
|
||||||
|> User.remote_user_changeset(new_user_data)
|
|
||||||
|> User.update_and_set_cache()
|
|
||||||
|
|
||||||
ActivityPub.update(%{
|
|
||||||
local: false,
|
|
||||||
to: data["to"] || [],
|
|
||||||
cc: data["cc"] || [],
|
|
||||||
object: object,
|
|
||||||
actor: actor_id,
|
|
||||||
activity_id: data["id"]
|
|
||||||
})
|
|
||||||
else
|
|
||||||
e ->
|
|
||||||
Logger.error(e)
|
|
||||||
:error
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue