mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-22 16:16:34 +00:00
Add pleroma.deactivated
to the Account entity (Mastodon API)
This commit is contained in:
parent
a0d71d3ccf
commit
520ee6c591
4 changed files with 16 additions and 0 deletions
|
@ -31,6 +31,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- Mastodon API: Add support for categories for custom emojis by reusing the group feature. <https://github.com/tootsuite/mastodon/pull/11196>
|
||||
- Mastodon API: Add support for muting/unmuting notifications
|
||||
- Mastodon API: Add support for the `blocked_by` attribute in the relationship API (`GET /api/v1/accounts/relationships`). <https://github.com/tootsuite/mastodon/pull/10373>
|
||||
- Mastodon API: Add `pleroma.deactivated` to the Account entity
|
||||
- Admin API: Return users' tags when querying reports
|
||||
- Admin API: Return avatar and display name when querying users
|
||||
- Admin API: Allow querying user by ID
|
||||
|
|
|
@ -47,6 +47,7 @@ Has these additional fields under the `pleroma` object:
|
|||
- `hide_follows`: boolean, true when the user has follow hiding enabled
|
||||
- `settings_store`: A generic map of settings for frontends. Opaque to the backend. Only returned in `verify_credentials` and `update_credentials`
|
||||
- `chat_token`: The token needed for Pleroma chat. Only returned in `verify_credentials`
|
||||
- `deactivated`: boolean, true when the user is deactivated
|
||||
|
||||
### Source
|
||||
|
||||
|
|
|
@ -137,6 +137,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|
|||
|> maybe_put_notification_settings(user, opts[:for])
|
||||
|> maybe_put_settings_store(user, opts[:for], opts)
|
||||
|> maybe_put_chat_token(user, opts[:for], opts)
|
||||
|> maybe_put_activation_status(user, opts[:for])
|
||||
end
|
||||
|
||||
defp username_from_nickname(string) when is_binary(string) do
|
||||
|
@ -197,6 +198,12 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|
|||
|
||||
defp maybe_put_notification_settings(data, _, _), do: data
|
||||
|
||||
defp maybe_put_activation_status(data, user, %User{info: %{is_admin: true}}) do
|
||||
Kernel.put_in(data, [:pleroma, :deactivated], user.info.deactivated)
|
||||
end
|
||||
|
||||
defp maybe_put_activation_status(data, _, _), do: data
|
||||
|
||||
defp image_url(%{"url" => [%{"href" => href} | _]}), do: href
|
||||
defp image_url(_), do: nil
|
||||
end
|
||||
|
|
|
@ -153,6 +153,13 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
assert expected == AccountView.render("account.json", %{user: user})
|
||||
end
|
||||
|
||||
test "Represent a deactivated user for an admin" do
|
||||
admin = insert(:user, %{info: %{is_admin: true}})
|
||||
deactivated_user = insert(:user, %{info: %{deactivated: true}})
|
||||
represented = AccountView.render("account.json", %{user: deactivated_user, for: admin})
|
||||
assert represented[:pleroma][:deactivated] == true
|
||||
end
|
||||
|
||||
test "Represent a smaller mention" do
|
||||
user = insert(:user)
|
||||
|
||||
|
|
Loading…
Reference in a new issue