Use actor_types() to determine whether the Update is for user

This commit is contained in:
Tusooa Zhu 2022-08-02 10:15:56 -04:00
parent 997f08b350
commit a4fa286d20
No known key found for this signature in database
GPG key ID: 7B467EDE43A08224
2 changed files with 7 additions and 3 deletions

View file

@ -163,8 +163,9 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
updated_object_id = updated_object["id"]
with {_, true} <- {:has_id, is_binary(updated_object_id)},
{_, user} <- {:user, Pleroma.User.get_by_ap_id(updated_object_id)} do
if user do
%{"type" => type} <- updated_object,
{_, is_user} <- {:is_user, type in Pleroma.Constants.actor_types()} do
if is_user do
handle_update_user(object, meta)
else
handle_update_object(object, meta)

View file

@ -118,7 +118,10 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
describe "update users" do
setup do
user = insert(:user, local: false)
{:ok, update_data, []} = Builder.update(user, %{"id" => user.ap_id, "name" => "new name!"})
{:ok, update_data, []} =
Builder.update(user, %{"id" => user.ap_id, "type" => "Person", "name" => "new name!"})
{:ok, update, _meta} = ActivityPub.persist(update_data, local: true)
%{user: user, update_data: update_data, update: update}