Cannot report a fake Create activity (the status is shown as nil)
tl;dr
Ok, after several months I finally found out the root cause of nil
statuses in reports.
Reproducing
- Post something from a remote account. Ensure no local user is following that account.
- Search for the object id of that post on the local server.
- Report it from the local server:
Pleroma.Web.CommonAPI.report(Pleroma.User.get_by_nickname("SWwind"), %{account_id: "ABIJ0dpJ3vVdlYH8nA", status_ids: ["APYKvAICWGDa2B0Dei"], comment: "foobar", forward: false})
- And we get
{:ok,
%Pleroma.Activity{
__meta__: #Ecto.Schema.Metadata<:loaded, "activities">,
actor: "https://kazv.moe/users/SWwind",
bookmark: #Ecto.Association.NotLoaded<association :bookmark is not loaded>,
data: %{
"actor" => "https://kazv.moe/users/SWwind",
"cc" => [],
"content" => "foobar",
"context" => "https://kazv.moe/contexts/031af056-8ba6-4cc4-9143-f3e29687ad6f",
"id" => "https://kazv.moe/activities/64e29e98-2039-49e7-b720-a91975020dca",
"object" => [
"https://lm.kazv.moe/users/testuser",
%{"deleted" => true, "id" => nil}
],
"published" => "2022-11-13T06:46:53.296688Z",
"state" => "open",
"to" => [],
"type" => "Flag"
},
id: "APYLXiH6cdREQss5lQ",
inserted_at: ~N[2022-11-13 06:46:53],
local: true,
notifications: #Ecto.Association.NotLoaded<association :notifications is not loaded>,
object: #Ecto.Association.NotLoaded<association :object is not loaded>,
pagination_id: nil,
recipients: [],
report_notes: #Ecto.Association.NotLoaded<association :report_notes is not loaded>,
thread_muted?: nil,
updated_at: ~N[2022-11-13 06:46:53],
user_actor: #Ecto.Association.NotLoaded<association :user_actor is not loaded>
}}
While:
Pleroma.Activity.get_by_id("APYKvAICWGDa2B0Dei")
06:49:55.927 [debug] QUERY OK source="activities" db=36.3ms idle=183.1ms
SELECT a0."id", a0."data", a0."local", a0."actor", a0."recipients", a0."inserted_at", a0."updated_at" FROM "activities" AS a0 WHERE (a0."id" = $1) AND (NOT (a0."actor" IN (SELECT su0."ap_id" FROM "users" AS su0 WHERE (su0."is_active" = FALSE) AND (NOT (su0."nickname" IS NULL)) AND (NOT (su0."nickname" LIKE 'internal.%'))))) [<<0, 0, 1, 132, 111, 183, 79, 161, 112, 115, 104, 104, 128, 152, 0, 0>>]
%Pleroma.Activity{
__meta__: #Ecto.Schema.Metadata<:loaded, "activities">,
actor: "https://lm.kazv.moe/users/testuser",
bookmark: #Ecto.Association.NotLoaded<association :bookmark is not loaded>,
data: %{
"actor" => "https://lm.kazv.moe/users/testuser",
"bcc" => [],
"bto" => [],
"cc" => ["https://www.w3.org/ns/activitystreams#Public"],
"context" => "https://lm.kazv.moe/contexts/34747291-0246-4710-b079-ac0b4b445fdd",
"object" => "https://lm.kazv.moe/objects/570c7cc4-5b1d-4b88-9fd0-abfcf23ef918",
"to" => ["https://lm.kazv.moe/users/testuser/followers"],
"type" => "Create"
},
id: "APYKvAICWGDa2B0Dei",
inserted_at: ~N[2022-11-13 06:39:55],
local: false,
notifications: #Ecto.Association.NotLoaded<association :notifications is not loaded>,
object: #Ecto.Association.NotLoaded<association :object is not loaded>,
pagination_id: nil,
recipients: ["https://lm.kazv.moe/users/testuser/followers",
"https://www.w3.org/ns/activitystreams#Public",
"https://lm.kazv.moe/users/testuser"],
report_notes: #Ecto.Association.NotLoaded<association :report_notes is not loaded>,
thread_muted?: nil,
updated_at: ~N[2022-11-13 06:39:55],
user_actor: #Ecto.Association.NotLoaded<association :user_actor is not loaded>
}
Apparently, it is because the Create does not actually have an id. And we should guard against this.
I'll fix it when I wake up.