Deleting user activities via mix task fails.
Environment
- Installation type:
-
OTP -
From source
-
- Pleroma version (could be found in the "Version" tab of settings in Pleroma-FE):
2.0.50-92-g69341cbc-develop
- Elixir version (
elixir -v
for from source installations, N/A for OTP):Elixir 1.10.2 (compiled with Erlang/OTP 21)
- Operating system: Debian 9.12
- PostgreSQL version (
postgres -V
): 9.6.17
Bug description
Upon attempting to delete all activities for a certain local user using mix pleroma.user delete_activities
, as part of an admin workflow to remove the user's account completely, I encountered an error. This appears to be a bug where the caller to Pleroma.Web.ActivityPub.ActivityPub.do_delete/2
which is apparently the delete
function in the same module, does not provide the second options
argument properly and the pattern match fails. Full command output included below.
pleroma@explosion:~/pleroma$ MIX_ENV=prod mix pleroma.user delete_activities xosominhngoc
01:22:28.760 [debug] connecting to myhtml_c48396cd@127.0.0.1 failed
01:22:28.767 [debug] Spawning myhtml_c48396cd@127.0.0.1
01:22:28.777 [debug] c-node is saying: initialising myhtml_c48396cd@127.0.0.1
01:22:28.777 [debug] c-node is saying: connecting to master_7efbaf05@127.0.0.1
01:22:28.777 [debug] connected to myhtml_c48396cd@127.0.0.1
01:22:38.476 [info] Found emoji packs:
01:22:39.301 [debug] QUERY OK source="users" db=791.8ms queue=1.3ms idle=30.0ms
SELECT distinct split_part(u0."nickname", '@', 2) FROM "users" AS u0 WHERE (u0."local" != $1) [true]
01:22:39.311 [debug] QUERY OK source="users" db=1.9ms queue=0.9ms idle=829.4ms
SELECT sum(u0."note_count") FROM "users" AS u0 WHERE (u0."local" = $1) AND (NOT (u0."nickname" IS NULL)) [true]
01:22:39.315 [debug] QUERY OK source="users" db=2.1ms queue=0.7ms idle=832.9ms
SELECT count(u0."id") FROM "users" AS u0 WHERE (u0."deactivated" != $1) AND (NOT (u0."nickname" IS NULL)) AND (u0."local" = $2) AND (NOT (u0."nickname" IS NULL)) [true, true]
01:22:39.453 [info] Gopher server disabled
01:22:39.510 [debug] QUERY OK source="users" db=23.5ms queue=1.8ms idle=1004.0ms
SELECT u0."id", u0."bio", u0."email", u0."name", u0."nickname", u0."password_hash", u0."keys", u0."ap_id", u0."avatar", u0."local", u0."follower_address", u0."following_address", u0."tags", u0."last_refreshed_at", u0."last_digest_emailed_at", u0."banner", u0."background", u0."source_data", u0."note_count", u0."follower_count", u0."following_count", u0."locked", u0."confirmation_pending", u0."password_reset_pending", u0."confirmation_token", u0."default_scope", u0."domain_blocks", u0."deactivated", u0."no_rich_text", u0."ap_enabled", u0."is_moderator", u0."is_admin", u0."show_role", u0."settings", u0."magic_key", u0."uri", u0."hide_followers_count", u0."hide_follows_count", u0."hide_followers", u0."hide_follows", u0."hide_favorites", u0."unread_conversation_count", u0."pinned_activities", u0."email_notifications", u0."mascot", u0."emoji", u0."pleroma_settings_store", u0."fields", u0."raw_fields", u0."discoverable", u0."invisible", u0."allow_following_move", u0."skip_thread_containment", u0."actor_type", u0."also_known_as", u0."notification_settings", u0."blocks", u0."mutes", u0."muted_reblogs", u0."muted_notifications", u0."subscribers", u0."inserted_at", u0."updated_at" FROM "users" AS u0 WHERE (u0."nickname" = $1) ["xosominhngoc"]
01:22:39.638 [debug] QUERY OK source="activities" db=14.0ms queue=0.7ms idle=20.4ms
SELECT a0."id", a0."data", a0."local", a0."actor", a0."recipients", a0."inserted_at", a0."updated_at" FROM "activities" AS a0 WHERE ((a0."data")->>'actor' = $1) AND (a0."id" > $2) ORDER BY a0."id" LIMIT $3 ["https://explosion.party/users/xosominhngoc", <<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>>, 50]
01:22:39.638 [debug] Object.normalize() called without preloaded object ("https://explosion.party/objects/790fd849-4744-4ba7-9691-7c630f2769a2"). Consider preloading the object
01:22:39.639 [debug] Backtrace: {:current_stacktrace, [{Process, :info, 2, [file: 'lib/process.ex', line: 765]}, {Pleroma.Object, :warn_on_no_object_preloaded, 1, [file: 'lib/pleroma/object.ex', line: 104]}, {Pleroma.Object, :normalize, 3, [file: 'lib/pleroma/object.ex', line: 127]}, {Pleroma.User, :delete_activity, 1, [file: 'lib/pleroma/user.ex', line: 1407]}, {Enum, :"-each/2-lists^foreach/1-0-", 2, [file: 'lib/enum.ex', line: 783]}, {Enum, :each, 2, [file: 'lib/enum.ex', line: 783]}, {Stream, :"-each/2-fun-0-", 4, [file: 'lib/stream.ex', line: 441]}]}
01:22:39.642 [debug] QUERY OK source="objects" db=1.6ms queue=0.4ms idle=35.8ms
SELECT o0."id", o0."data", o0."inserted_at", o0."updated_at" FROM "objects" AS o0 WHERE ((o0."data")->>'id' = $1) ["https://explosion.party/objects/790fd849-4744-4ba7-9691-7c630f2769a2"]
01:22:39.642 [debug] QUERY OK db=0.1ms idle=36.6ms
begin []
01:22:39.642 [debug] QUERY OK db=0.1ms
rollback []
** (FunctionClauseError) no function clause matching in Pleroma.Web.ActivityPub.ActivityPub.do_delete/2
The following arguments were given to Pleroma.Web.ActivityPub.ActivityPub.do_delete/2:
# 1
%Pleroma.Object{__meta__: #Ecto.Schema.Metadata<:loaded, "objects">, data: %{"deleted" => "2020-01-19T19:53:28.200494Z", "formerType" => "Note", "id" => "https://explosion.party/objects/790fd849-4744-4ba7-9691-7c630f2769a2", "type" => "Tombstone"}, id: 16991675, inserted_at: ~N[2020-01-06 07:04:34], updated_at: ~N[2020-01-19 19:53:28]}
# 2
[]
Attempted function clauses (showing 2 out of 2):
defp do_delete(%Pleroma.User{ap_id: ap_id, follower_address: follower_address} = user, _)
defp do_delete(%Pleroma.Object{data: %{"id" => id, "actor" => actor}} = object, options)
(pleroma 2.0.50-92-g69341cbc-develop) Pleroma.Web.ActivityPub.ActivityPub.do_delete/2
(ecto_sql 3.3.4) lib/ecto/adapters/sql.ex:886: anonymous fn/3 in Ecto.Adapters.SQL.checkout_or_transaction/4
(db_connection 2.2.1) lib/db_connection.ex:1427: DBConnection.run_transaction/4
(pleroma 2.0.50-92-g69341cbc-develop) lib/pleroma/web/activity_pub/activity_pub.ex:538: Pleroma.Web.ActivityPub.ActivityPub.delete/2
(elixir 1.10.2) lib/enum.ex:783: Enum."-each/2-lists^foreach/1-0-"/2
(elixir 1.10.2) lib/enum.ex:783: Enum.each/2
(elixir 1.10.2) lib/stream.ex:441: anonymous fn/4 in Stream.each/2
(elixir 1.10.2) lib/stream.ex:1540: Stream.do_unfold/4