### Fixed
- Report emails now include functional links to profiles of remote user accounts
- Not being able to log in to some third-party apps when logged in to MastoFE
+- MRF: `Delete` activities being exempt from MRF policies
<details>
<summary>API Changes</summary>
def normalize(ap_id) when is_binary(ap_id), do: get_by_ap_id_with_object(ap_id)
def normalize(_), do: nil
- def delete_by_ap_id(id) when is_binary(id) do
+ def delete_all_by_object_ap_id(id) when is_binary(id) do
id
|> Queries.by_object_id()
+ |> Queries.exclude_type("Delete")
|> select([u], u)
|> Repo.delete_all()
|> elem(1)
|> purge_web_resp_cache()
end
- def delete_by_ap_id(_), do: nil
+ def delete_all_by_object_ap_id(_), do: nil
defp purge_web_resp_cache(%Activity{} = activity) do
%{path: path} = URI.parse(activity.data["id"])
where: fragment("(?)->>'type' = ?", activity.data, ^activity_type)
)
end
+
+ @spec exclude_type(query, String.t()) :: query
+ def exclude_type(query \\ Activity, activity_type) do
+ from(
+ activity in query,
+ where: fragment("(?)->>'type' != ?", activity.data, ^activity_type)
+ )
+ end
end
def delete(%Object{data: %{"id" => id}} = object) do
with {:ok, _obj} = swap_object_with_tombstone(object),
- deleted_activity = Activity.delete_by_ap_id(id),
+ deleted_activity = Activity.delete_all_by_object_ap_id(id),
{:ok, true} <- Cachex.del(:object_cache, "object:#{id}"),
{:ok, _} <- Cachex.del(:web_resp_cache, URI.parse(id).path) do
{:ok, object, deleted_activity}
user = User.get_cached_by_ap_id(actor)
to = (object.data["to"] || []) ++ (object.data["cc"] || [])
- with {:ok, object, activity} <- Object.delete(object),
+ with create_activity <- Activity.get_create_by_object_ap_id(id),
data <-
%{
"type" => "Delete",
"actor" => actor,
"object" => id,
"to" => to,
- "deleted_activity_id" => activity && activity.id
+ "deleted_activity_id" => create_activity && create_activity.id
}
|> maybe_put("id", activity_id),
{:ok, activity} <- insert(data, local, false),
+ {:ok, object, _create_activity} <- Object.delete(object),
stream_out_participations(object, user),
_ <- decrease_replies_count_if_reply(object),
{:ok, _actor} <- decrease_note_count_if_public(user, object),
assert json_response(conn1, :ok)
assert Enum.any?(conn1.resp_headers, &(&1 == {"x-cache", "MISS from Pleroma"}))
- Activity.delete_by_ap_id(activity.object.data["id"])
+ Activity.delete_all_by_object_ap_id(activity.object.data["id"])
conn2 =
conn
assert %{data: data, object: object} = Activity.get_by_ap_id_with_object(ap_id)
assert object.data["repliesCount"] == 0
end
+
+ test "it passes delete activity through MRF before deleting the object" do
+ rewrite_policy = Pleroma.Config.get([:instance, :rewrite_policy])
+ Pleroma.Config.put([:instance, :rewrite_policy], Pleroma.Web.ActivityPub.MRF.DropPolicy)
+
+ on_exit(fn -> Pleroma.Config.put([:instance, :rewrite_policy], rewrite_policy) end)
+
+ note = insert(:note_activity)
+ object = Object.normalize(note)
+
+ {:error, {:reject, _}} = ActivityPub.delete(object)
+
+ assert Activity.get_by_id(note.id)
+ assert Repo.get(Object, object.id).data["type"] == object.data["type"]
+ end
end
describe "timeline post-processing" do