Use actor_types() to determine whether the Update is for user
This commit is contained in:
parent
997f08b350
commit
a4fa286d20
2 changed files with 7 additions and 3 deletions
|
@ -163,8 +163,9 @@ def handle(%{data: %{"type" => "Update", "object" => updated_object}} = object,
|
|||
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)
|
||||
|
|
|
@ -118,7 +118,10 @@ test "it blocks but does not unfollow if the relevant setting is set", %{
|
|||
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}
|
||||
|
|
Loading…
Reference in a new issue