From b1e1db82bc2c076f2a7858ec63017c10dda1966b Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Mon, 1 Mar 2021 11:29:10 -0600 Subject: [PATCH] Store application details in the object under the generator key, not application key --- lib/pleroma/constants.ex | 2 +- lib/pleroma/web/common_api/activity_draft.ex | 2 +- lib/pleroma/web/mastodon_api/controllers/status_controller.ex | 6 +++--- lib/pleroma/web/mastodon_api/views/status_view.ex | 4 ++-- test/pleroma/web/activity_pub/transmogrifier_test.exs | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/pleroma/constants.ex b/lib/pleroma/constants.ex index 9ee836d5d..b24338cc6 100644 --- a/lib/pleroma/constants.ex +++ b/lib/pleroma/constants.ex @@ -19,7 +19,7 @@ defmodule Pleroma.Constants do "context_id", "deleted_activity_id", "pleroma_internal", - "application" + "generator" ] ) diff --git a/lib/pleroma/web/common_api/activity_draft.ex b/lib/pleroma/web/common_api/activity_draft.ex index d7dcdad90..73f1b0931 100644 --- a/lib/pleroma/web/common_api/activity_draft.ex +++ b/lib/pleroma/web/common_api/activity_draft.ex @@ -190,7 +190,7 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do Utils.make_note_data(draft) |> Map.put("emoji", emoji) |> Map.put("source", draft.status) - |> Map.put("application", draft.params[:application]) + |> Map.put("generator", draft.params[:generator]) %__MODULE__{draft | object: object} end diff --git a/lib/pleroma/web/mastodon_api/controllers/status_controller.ex b/lib/pleroma/web/mastodon_api/controllers/status_controller.ex index b8a7b2a0a..b051fca74 100644 --- a/lib/pleroma/web/mastodon_api/controllers/status_controller.ex +++ b/lib/pleroma/web/mastodon_api/controllers/status_controller.ex @@ -423,11 +423,11 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do defp put_application(params, %{assigns: %{token: %Token{user: %User{} = user} = token}} = _conn) do if user.disclose_client do %{client_name: client_name, website: website} = Repo.preload(token, :app).app - Map.put(params, :application, %{type: "Application", name: client_name, url: website}) + Map.put(params, :generator, %{type: "Application", name: client_name, url: website}) else - Map.put(params, :application, nil) + Map.put(params, :generator, nil) end end - defp put_application(params, _), do: Map.put(params, :application, nil) + defp put_application(params, _), do: Map.put(params, :generator, nil) end diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index 792197a4a..bac897a57 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -180,7 +180,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do media_attachments: reblogged[:media_attachments] || [], mentions: mentions, tags: reblogged[:tags] || [], - application: build_application(activity_object.data["application"]), + application: build_application(activity_object.data["generator"]), language: nil, emojis: [], pleroma: %{ @@ -345,7 +345,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do poll: render(PollView, "show.json", object: object, for: opts[:for]), mentions: mentions, tags: build_tags(tags), - application: build_application(object.data["application"]), + application: build_application(object.data["generator"]), language: nil, emojis: build_emojis(object.data["emoji"]), pleroma: %{ diff --git a/test/pleroma/web/activity_pub/transmogrifier_test.exs b/test/pleroma/web/activity_pub/transmogrifier_test.exs index f6a8cbb6f..211e535a5 100644 --- a/test/pleroma/web/activity_pub/transmogrifier_test.exs +++ b/test/pleroma/web/activity_pub/transmogrifier_test.exs @@ -205,7 +205,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do {:ok, activity} = CommonAPI.post(user, %{ status: "#2hu :firefox:", - application: %{type: "Application", name: "TestClient", url: "https://pleroma.social"} + generator: %{type: "Application", name: "TestClient", url: "https://pleroma.social"} }) # Ensure injected application data made it into the activity @@ -215,7 +215,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do type: "Application", name: "TestClient", url: "https://pleroma.social" - } == activity.object.data["application"] + } == activity.object.data["generator"] {:ok, modified} = Transmogrifier.prepare_outgoing(activity.data) @@ -226,7 +226,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do assert is_nil(modified["object"]["announcements"]) assert is_nil(modified["object"]["announcement_count"]) assert is_nil(modified["object"]["context_id"]) - assert is_nil(modified["object"]["application"]) + assert is_nil(modified["object"]["generator"]) end test "it strips internal fields of article" do