- `nicknames`: nicknames array
- Response:
- On failure: `{"error": "…"}`
- - On success: JSON of the `user.info`
+ - On success: JSON of the user
## DEPRECATED `DELETE /api/pleroma/admin/users/:nickname/permission_group/:permission_group`
- `nicknames`: nicknames array
- Response:
- On failure: `{"error": "…"}`
- - On success: JSON of the `user.info`
+ - On success: JSON of the user
- Note: An admin cannot revoke their own admin status.
## `PATCH /api/pleroma/admin/users/activate`
field(:settings, :map, default: nil)
field(:magic_key, :string, default: nil)
field(:uri, :string, default: nil)
- field(:topic, :string, default: nil)
- field(:hub, :string, default: nil)
- field(:salmon, :string, default: nil)
field(:hide_followers_count, :boolean, default: false)
field(:hide_follows_count, :boolean, default: false)
field(:hide_followers, :boolean, default: false)
:settings,
:magic_key,
:uri,
- :topic,
- :hub,
- :salmon,
:hide_followers_count,
:hide_follows_count,
:hide_followers,
:locked,
:magic_key,
:uri,
- :hub,
- :topic,
- :salmon,
:hide_followers,
:hide_follows,
:hide_followers_count,
{:ok, key}
end
- def public_key_from_info(_), do: {:error, "not found key"}
+ def public_key(_), do: {:error, "not found key"}
def get_public_key_for_ap_id(ap_id) do
with {:ok, %User{} = user} <- get_or_fetch_by_ap_id(ap_id),
:tag_users,
:untag_users,
:right_add,
- :right_delete,
- :set_activation_status
+ :right_delete
]
)
"nicknames" => nicknames
})
when permission_group in ["moderator", "admin"] do
- info = Map.put(%{}, "is_" <> permission_group, true)
+ update = %{:"is_#{permission_group}" => true}
users = nicknames |> Enum.map(&User.get_cached_by_nickname/1)
- User.update_info(users, &User.Info.admin_api_update(&1, info))
+ for u <- users, do: User.admin_api_update(u, update)
ModerationLog.insert_log(%{
action: "grant",
permission: permission_group
})
- json(conn, info)
+ json(conn, update)
end
def right_add_multiple(conn, _) do
)
when permission_group in ["moderator", "admin"] do
with false <- Enum.member?(nicknames, admin_nickname) do
- info = Map.put(%{}, "is_" <> permission_group, false)
+ update = %{:"is_#{permission_group}" => false}
users = nicknames |> Enum.map(&User.get_cached_by_nickname/1)
- User.update_info(users, &User.Info.admin_api_update(&1, info))
+ for u <- users, do: User.admin_api_update(u, update)
ModerationLog.insert_log(%{
action: "revoke",
permission: permission_group
})
- json(conn, info)
+ json(conn, update)
else
_ -> render_error(conn, :forbidden, "You can't revoke your own admin/moderator status.")
end
render_error(conn, :forbidden, "You can't revoke your own admin status.")
end
- def set_activation_status(%{assigns: %{user: admin}} = conn, %{
- "nickname" => nickname,
- "status" => status
- }) do
- with {:ok, status} <- Ecto.Type.cast(:boolean, status),
- %User{} = user <- User.get_cached_by_nickname(nickname),
- {:ok, _} <- User.deactivate(user, !status) do
- action = if(user.deactivated, do: "activate", else: "deactivate")
-
- ModerationLog.insert_log(%{
- actor: admin,
- subject: user,
- action: action
- })
-
- json_response(conn, :no_content, "")
- end
- end
-
def relay_list(conn, _params) do
with {:ok, list} <- Relay.list() do
json(conn, %{relays: list})
_ ->
conn
|> put_status(500)
+ end
+ end
def relay_follow(%{assigns: %{user: admin}} = conn, %{"relay_url" => target}) do
with {:ok, _message} <- Relay.follow(target) do
:settings,
:magic_key,
:uri,
- :topic,
- :hub,
- :salmon,
:hide_followers_count,
:hide_follows_count,
:hide_followers,
add(:settings, :map, default: nil)
add(:magic_key, :text, default: nil)
add(:uri, :text, default: nil)
- add(:topic, :text, default: nil)
- add(:hub, :text, default: nil)
- add(:salmon, :text, default: nil)
add(:hide_followers_count, :boolean, default: false, null: false)
add(:hide_follows_count, :boolean, default: false, null: false)
add(:hide_followers, :boolean, default: false, null: false)
[%{read: true}] = Participation.for_user(user)
[%{read: false} = participation] = Participation.for_user(other_user)
- assert User.get_cached_by_id(user.id).info.unread_conversation_count == 0
- assert User.get_cached_by_id(other_user.id).info.unread_conversation_count == 1
+ assert User.get_cached_by_id(user.id).unread_conversation_count == 0
+ assert User.get_cached_by_id(other_user.id).unread_conversation_count == 1
{:ok, _} =
CommonAPI.post(other_user, %{
[%{read: false}] = Participation.for_user(user)
[%{read: true}] = Participation.for_user(other_user)
- assert User.get_cached_by_id(user.id).info.unread_conversation_count == 1
- assert User.get_cached_by_id(other_user.id).info.unread_conversation_count == 0
+ assert User.get_cached_by_id(user.id).unread_conversation_count == 1
+ assert User.get_cached_by_id(other_user.id).unread_conversation_count == 0
end
test "for a new conversation, it sets the recipents of the participation" do
"visibility" => "direct"
})
- assert User.get_cached_by_id(user_one.id).info.unread_conversation_count == 0
- assert User.get_cached_by_id(user_two.id).info.unread_conversation_count == 1
+ assert User.get_cached_by_id(user_one.id).unread_conversation_count == 0
+ assert User.get_cached_by_id(user_two.id).unread_conversation_count == 1
[%{"id" => direct_conversation_id, "unread" => true}] =
conn
[participation2, participation1] = Participation.for_user(other_user)
assert Participation.get(participation2.id).read == false
assert Participation.get(participation1.id).read == false
- assert User.get_cached_by_id(other_user.id).info.unread_conversation_count == 2
+ assert User.get_cached_by_id(other_user.id).unread_conversation_count == 2
[%{"unread" => false}, %{"unread" => false}] =
conn
[participation2, participation1] = Participation.for_user(other_user)
assert Participation.get(participation2.id).read == true
assert Participation.get(participation1.id).read == true
- assert User.get_cached_by_id(other_user.id).info.unread_conversation_count == 0
+ assert User.get_cached_by_id(other_user.id).unread_conversation_count == 0
end
describe "POST /api/v1/pleroma/notifications/read" do