diff options
author | tusooa <tusooa@kazv.moe> | 2024-03-10 13:14:19 +0000 |
---|---|---|
committer | tusooa <tusooa@kazv.moe> | 2024-03-10 13:14:19 +0000 |
commit | df7a8d4efe669c14775dd2bedf4b20dade6d7b66 (patch) | |
tree | caf7547e82379d67ef65b3d1c08201d279312dd1 /lib | |
parent | 72daf522c9af52832525fc002df061703aabca7f (diff) | |
parent | c0c4a9ed0d3cd154de15a8bb0767e2d4e5f4900f (diff) | |
download | pleroma-df7a8d4efe669c14775dd2bedf4b20dade6d7b66.tar.gz pleroma-df7a8d4efe669c14775dd2bedf4b20dade6d7b66.zip |
Merge branch 'instance-contact-account' into 'develop'
Add contact account to InstanceView
See merge request pleroma/pleroma!3960
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/mastodon_api/views/instance_view.ex | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/pleroma/web/mastodon_api/views/instance_view.ex b/lib/pleroma/web/mastodon_api/views/instance_view.ex index e4c6c81e1..84e9a0d3c 100644 --- a/lib/pleroma/web/mastodon_api/views/instance_view.ex +++ b/lib/pleroma/web/mastodon_api/views/instance_view.ex @@ -28,6 +28,7 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do |> to_string, registrations: Keyword.get(instance, :registrations_open), approval_required: Keyword.get(instance, :account_approval_required), + contact_account: contact_account(Keyword.get(instance, :contact_username)), configuration: configuration(), # Extra (not present in Mastodon): max_toot_chars: Keyword.get(instance, :limit), @@ -68,7 +69,7 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do }, contact: %{ email: Keyword.get(instance, :email), - account: nil + account: contact_account(Keyword.get(instance, :contact_username)) }, # Extra (not present in Mastodon): pleroma: pleroma_configuration2(instance) @@ -170,6 +171,22 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do } 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 + defp configuration do %{ accounts: %{ |