diff options
author | marcin mikołajczak <me@mkljczk.pl> | 2024-09-14 17:46:09 +0000 |
---|---|---|
committer | marcin mikołajczak <me@mkljczk.pl> | 2024-09-14 17:46:09 +0000 |
commit | 0111659a1f8e637b046c905551d7d5251d6c2efa (patch) | |
tree | f84b43becfd45898ebad02eb7afe789ef7337c77 /lib | |
parent | abf38b405d8d517269adc88564756ffd34f11297 (diff) | |
parent | 6d5ae4d2e91f8ea75115c0ffcdd1d94a24c9dc31 (diff) | |
download | pleroma-0111659a1f8e637b046c905551d7d5251d6c2efa.tar.gz pleroma-0111659a1f8e637b046c905551d7d5251d6c2efa.zip |
Merge branch 'list-id-visibility' into 'develop'
Include list id in StatusView
See merge request pleroma/pleroma!4246
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/api_spec/schemas/status.ex | 6 | ||||
-rw-r--r-- | lib/pleroma/web/mastodon_api/views/status_view.ex | 13 |
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/pleroma/web/api_spec/schemas/status.ex b/lib/pleroma/web/api_spec/schemas/status.ex index 6e537b5da..25548d75b 100644 --- a/lib/pleroma/web/api_spec/schemas/status.ex +++ b/lib/pleroma/web/api_spec/schemas/status.ex @@ -249,6 +249,12 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do nullable: true, description: "A datetime (ISO 8601) that states when the post was pinned or `null` if the post is not pinned" + }, + list_id: %Schema{ + type: :integer, + nullable: true, + description: + "The ID of the list the post is addressed to (if any, only returned to author)" } } }, diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index 1b78477d0..3bf870c24 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -465,7 +465,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do parent_visible: visible_for_user?(reply_to, opts[:for]), pinned_at: pinned_at, quotes_count: object.data["quotesCount"] || 0, - bookmark_folder: bookmark_folder + bookmark_folder: bookmark_folder, + list_id: get_list_id(object, client_posted_this_activity) } } end @@ -835,4 +836,14 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do nil end end + + defp get_list_id(object, client_posted_this_activity) do + with true <- client_posted_this_activity, + %{data: %{"listMessage" => list_ap_id}} when is_binary(list_ap_id) <- object, + %{id: list_id} <- Pleroma.List.get_by_ap_id(list_ap_id) do + list_id + else + _ -> nil + end + end end |