StatusView: implement pleroma.context field
authorHélène <pleroma-dev@helene.moe>
Sun, 7 Aug 2022 18:39:35 +0000 (20:39 +0200)
committerFloatingGhost <hannah@coffee-and-dreams.uk>
Sun, 7 Aug 2022 19:48:08 +0000 (20:48 +0100)
This field replaces the now deprecated conversation_id field, and now
exposes the ActivityPub object `context` directly via the MastoAPI
instead of relying on StatusNet-era data concepts.

lib/pleroma/web/api_spec/schemas/status.ex
lib/pleroma/web/mastodon_api/views/status_view.ex
test/pleroma/web/mastodon_api/controllers/status_controller_test.exs
test/pleroma/web/mastodon_api/views/status_view_test.exs

index 60db8ad6fa60324a050213e7edb756be01973ee7..dd40255550af8c24218b07cc62852981b924addd 100644 (file)
@@ -152,9 +152,14 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
             description:
               "A map consisting of alternate representations of the `content` property with the key being it's mimetype. Currently the only alternate representation supported is `text/plain`"
           },
+          context: %Schema{
+            type: :string,
+            description: "The thread identifier the status is associated with"
+          },
           conversation_id: %Schema{
             type: :integer,
-            description: "The ID of the AP context the status is associated with (if any)"
+            deprecated: true,
+            description: "The ID of the AP context the status is associated with (if any); deprecated, please use `context` instead"
           },
           direct_conversation_id: %Schema{
             type: :integer,
@@ -356,6 +361,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
       "pinned" => false,
       "pleroma" => %{
         "content" => %{"text/plain" => "foobar"},
+        "context" => "http://localhost:4001/objects/8b4c0c80-6a37-4d2a-b1b9-05a19e3875aa",
         "conversation_id" => 345_972,
         "direct_conversation_id" => nil,
         "emoji_reactions" => [],
index 2153c757d611783d72a41045bb1498235628f5eb..f0fe9a4bae5bd9dcedd8b3c428c6855b5f588ef3 100644 (file)
@@ -378,6 +378,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
       pleroma: %{
         local: activity.local,
         conversation_id: get_context_id(activity),
+        context: object.data["context"],
         in_reply_to_account_acct: reply_to_user && reply_to_user.nickname,
         content: %{"text/plain" => content_plaintext},
         spoiler_text: %{"text/plain" => summary},
index 1a3bc2990bb45702c0f7e08b0542a289dbb9b807..ea168f6c5183b5b3fd63ada2d485e2f7f19240c4 100644 (file)
@@ -264,6 +264,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
         |> Map.put("url", nil)
         |> Map.put("uri", nil)
         |> Map.put("created_at", nil)
+        |> Kernel.put_in(["pleroma", "context"], nil)
         |> Kernel.put_in(["pleroma", "conversation_id"], nil)
 
       fake_conn =
@@ -287,6 +288,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
         |> Map.put("url", nil)
         |> Map.put("uri", nil)
         |> Map.put("created_at", nil)
+        |> Kernel.put_in(["pleroma", "context"], nil)
         |> Kernel.put_in(["pleroma", "conversation_id"], nil)
 
       assert real_status == fake_status
index e56d095c4c51fa0f9c8d3c11a6ddea1990272d07..fb3255927a97aa591467bead785a9ef8813824fb 100644 (file)
@@ -292,6 +292,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
       pleroma: %{
         local: true,
         conversation_id: convo_id,
+        context: object_data["context"],
         in_reply_to_account_acct: nil,
         content: %{"text/plain" => HTML.strip_tags(object_data["content"])},
         spoiler_text: %{"text/plain" => HTML.strip_tags(object_data["summary"])},