Skip to content
Snippets Groups Projects
Commit 31a4d42c authored by lain's avatar lain
Browse files

SideEffects: Handle user updating.

parent 75670a99
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,18 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
def handle(object, meta \\ [])
# Tasks this handles:
# Update the user
def handle(%{data: %{"type" => "Update", "object" => updated_object}} = object, meta) do
{:ok, new_user_data} = ActivityPub.user_data_from_user_object(updated_object)
User.get_by_ap_id(updated_object["id"])
|> User.remote_user_changeset(new_user_data)
|> User.update_and_set_cache()
{:ok, object, meta}
end
# Tasks this handles:
# - Add like to object
# - Set up notification
......
......@@ -64,6 +64,22 @@ test "it streams out notifications and streams" do
end
end
describe "update users" do
setup do
user = insert(:user)
{:ok, update_data, []} = Builder.update(user, %{"id" => user.ap_id, "name" => "new name!"})
{:ok, update, _meta} = ActivityPub.persist(update_data, local: true)
%{user: user, update_data: update_data, update: update}
end
test "it updates the user", %{user: user, update: update} do
{:ok, _, _} = SideEffects.handle(update)
user = User.get_by_id(user.id)
assert user.name == "new name!"
end
end
describe "delete objects" do
setup do
user = insert(:user)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment