From 4811eefa6e4cbdaa92fc2e003037506539e493b1 Mon Sep 17 00:00:00 2001 From: lain Date: Mon, 11 Mar 2019 13:48:27 +0100 Subject: [PATCH 1/2] MastoAPI StatusView: Add locality indicator. --- docs/Differences-in-MastodonAPI-Responses.md | 6 ++++++ lib/pleroma/web/mastodon_api/views/status_view.ex | 10 ++++++++-- test/web/mastodon_api/status_view_test.exs | 5 ++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/docs/Differences-in-MastodonAPI-Responses.md b/docs/Differences-in-MastodonAPI-Responses.md index 3026e1173..bb3cf33c8 100644 --- a/docs/Differences-in-MastodonAPI-Responses.md +++ b/docs/Differences-in-MastodonAPI-Responses.md @@ -13,3 +13,9 @@ Some apps operate under the assumption that no more than 4 attachments can be re ## Timelines Adding the parameter `with_muted=true` to the timeline queries will also return activities by muted (not by blocked!) users. + +## Statuses + +Has these additional fields under the 'pleroma' object: + +- `local`: true if the post was made on the local instance. diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index 3468c0e1c..bf3aaf025 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -102,7 +102,10 @@ def render( website: nil }, language: nil, - emojis: [] + emojis: [], + pleroma: %{ + local: activity.local + } } end @@ -181,7 +184,10 @@ def render("status.json", %{activity: %{data: %{"object" => object}} = activity} website: nil }, language: nil, - emojis: build_emojis(activity.data["object"]["emoji"]) + emojis: build_emojis(activity.data["object"]["emoji"]), + pleroma: %{ + local: activity.local + } } end diff --git a/test/web/mastodon_api/status_view_test.exs b/test/web/mastodon_api/status_view_test.exs index 351dbf673..485a0b4f7 100644 --- a/test/web/mastodon_api/status_view_test.exs +++ b/test/web/mastodon_api/status_view_test.exs @@ -120,7 +120,10 @@ test "a note activity" do static_url: "corndog.png", visible_in_picker: false } - ] + ], + pleroma: %{ + local: true + } } assert status == expected From 66774b5567c10005b2be810433d7f3d401e12520 Mon Sep 17 00:00:00 2001 From: lambda Date: Mon, 11 Mar 2019 13:21:03 +0000 Subject: [PATCH 2/2] Update Differences-in-MastodonAPI-Responses.md --- docs/Differences-in-MastodonAPI-Responses.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Differences-in-MastodonAPI-Responses.md b/docs/Differences-in-MastodonAPI-Responses.md index bb3cf33c8..667664f4e 100644 --- a/docs/Differences-in-MastodonAPI-Responses.md +++ b/docs/Differences-in-MastodonAPI-Responses.md @@ -16,6 +16,6 @@ Adding the parameter `with_muted=true` to the timeline queries will also return ## Statuses -Has these additional fields under the 'pleroma' object: +Has these additional fields under the `pleroma` object: - `local`: true if the post was made on the local instance.