summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormarcin mikołajczak <git@mkljczk.pl>2023-10-26 23:30:38 +0200
committermarcin mikołajczak <git@mkljczk.pl>2023-10-26 23:32:08 +0200
commit6b8c5e12dfe759ac1286e81e72ad7f8727e01386 (patch)
treeed870245ec53a55d8c5f54534ca83e9b3547151d /lib
parente3ea311cd594d4f0bc8c4e05ca8eb1eee18ae6be (diff)
downloadpleroma-6b8c5e12dfe759ac1286e81e72ad7f8727e01386.tar.gz
pleroma-6b8c5e12dfe759ac1286e81e72ad7f8727e01386.zip
Add contact account to InstanceView
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/mastodon_api/views/instance_view.ex17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/pleroma/web/mastodon_api/views/instance_view.ex b/lib/pleroma/web/mastodon_api/views/instance_view.ex
index 1b01d7371..06df63b0f 100644
--- a/lib/pleroma/web/mastodon_api/views/instance_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/instance_view.ex
@@ -30,6 +30,7 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do
languages: Keyword.get(instance, :languages, ["en"]),
registrations: Keyword.get(instance, :registrations_open),
approval_required: Keyword.get(instance, :account_approval_required),
+ contact_account: contact_account(Keyword.get(instance, :contact_username)),
# Extra (not present in Mastodon):
max_toot_chars: Keyword.get(instance, :limit),
max_media_attachments: Keyword.get(instance, :max_media_attachments),
@@ -141,4 +142,20 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do
value_length: Config.get([:instance, :account_field_value_length])
}
end
+
+ defp contact_account(nil), do: nil
+
+ defp contact_account("@" <> username) do
+ contact_account(username)
+ end
+
+ defp contact_account(username) do
+ user = Pleroma.User.get_cached_by_nickname(username)
+
+ if user do
+ Pleroma.Web.MastodonAPI.AccountView.render("show.json", %{user: user, for: nil})
+ else
+ nil
+ end
+ end
end