projects
/
akkoma
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
26b620d
)
Store the client application data in ActivityStreams format
author
Mark Felder
<feld@feld.me>
Sat, 27 Feb 2021 00:14:57 +0000
(18:14 -0600)
committer
Mark Felder
<feld@feld.me>
Sat, 27 Feb 2021 00:14:57 +0000
(18:14 -0600)
lib/pleroma/web/mastodon_api/controllers/status_controller.ex
patch
|
blob
|
history
lib/pleroma/web/mastodon_api/views/status_view.ex
patch
|
blob
|
history
test/pleroma/web/activity_pub/transmogrifier_test.exs
patch
|
blob
|
history
diff --git
a/lib/pleroma/web/mastodon_api/controllers/status_controller.ex
b/lib/pleroma/web/mastodon_api/controllers/status_controller.ex
index 2655d6b6e986483bff145942dd10a42e9ed2b0a2..b8a7b2a0afd5fa9aff6ecd6d3a731c2339d43b64 100644
(file)
--- a/
lib/pleroma/web/mastodon_api/controllers/status_controller.ex
+++ b/
lib/pleroma/web/mastodon_api/controllers/status_controller.ex
@@
-423,7
+423,7
@@
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
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, %{
name: client_name, website
: website})
+ Map.put(params, :application, %{
type: "Application", name: client_name, url
: website})
else
Map.put(params, :application, nil)
end
else
Map.put(params, :application, 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 a456509883273b8f5e2729316dcc8a0e2c83a65b..792197a4a4b49ccd85f70df99ada329c7f859e88 100644
(file)
--- 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] || [],
media_attachments: reblogged[:media_attachments] || [],
mentions: mentions,
tags: reblogged[:tags] || [],
- application:
activity_object.data["application"] || nil
,
+ application:
build_application(activity_object.data["application"])
,
language: nil,
emojis: [],
pleroma: %{
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),
poll: render(PollView, "show.json", object: object, for: opts[:for]),
mentions: mentions,
tags: build_tags(tags),
- application:
object.data["application"] || nil
,
+ application:
build_application(object.data["application"])
,
language: nil,
emojis: build_emojis(object.data["emoji"]),
pleroma: %{
language: nil,
emojis: build_emojis(object.data["emoji"]),
pleroma: %{
@@
-534,4
+534,8
@@
defmodule Pleroma.Web.MastodonAPI.StatusView do
me: !!(current_user && current_user.ap_id in users)
}
end
me: !!(current_user && current_user.ap_id in users)
}
end
+
+ @spec build_application(map() | nil) :: map() | nil
+ defp build_application(%{type: _type, name: name, url: url}), do: %{name: name, website: url}
+ defp build_application(_), do: nil
end
end
diff --git
a/test/pleroma/web/activity_pub/transmogrifier_test.exs
b/test/pleroma/web/activity_pub/transmogrifier_test.exs
index 33ccbe2a78bb5173e854e4e7cbe2188e856dfe8f..f6a8cbb6fd971c1ba23cf7ae158bdd22bbe05e76 100644
(file)
--- a/
test/pleroma/web/activity_pub/transmogrifier_test.exs
+++ b/
test/pleroma/web/activity_pub/transmogrifier_test.exs
@@
-205,14
+205,17
@@
defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
{:ok, activity} =
CommonAPI.post(user, %{
status: "#2hu :firefox:",
{:ok, activity} =
CommonAPI.post(user, %{
status: "#2hu :firefox:",
- application: %{
name: "TestClient", website
: "https://pleroma.social"}
+ application: %{
type: "Application", name: "TestClient", url
: "https://pleroma.social"}
})
# Ensure injected application data made it into the activity
# as we don't have a Token to derive it from, otherwise it will
# be nil and the test will pass
})
# Ensure injected application data made it into the activity
# as we don't have a Token to derive it from, otherwise it will
# be nil and the test will pass
- assert %{"application" => %{name: "TestClient", website: "https://pleroma.social"}} =
- activity.object.data
+ assert %{
+ type: "Application",
+ name: "TestClient",
+ url: "https://pleroma.social"
+ } == activity.object.data["application"]
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)