mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-12-23 01:35:28 +00:00
[#1304]. Post-merge fixes. Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into 1304-user-info-deprecation
# Conflicts: # CHANGELOG.md # lib/pleroma/notification.ex # lib/pleroma/user.ex # lib/pleroma/user/info.ex # lib/pleroma/web/admin_api/admin_api_controller.ex # lib/pleroma/web/ostatus/handlers/follow_handler.ex # lib/pleroma/web/ostatus/ostatus.ex # lib/pleroma/web/salmon/salmon.ex # lib/pleroma/web/websub/websub.ex # test/web/admin_api/admin_api_controller_test.exs # test/web/federator_test.exs # test/web/mastodon_api/controllers/conversation_controller_test.exs # test/web/ostatus/ostatus_controller_test.exs # test/web/ostatus/ostatus_test.exs # test/web/salmon/salmon_test.exs # test/web/websub/websub_test.exs
This commit is contained in:
parent
c6fdfbc4f1
commit
ee04fbc35a
|
@ -180,7 +180,7 @@ Note: Available `:permission_group` is currently moderator and admin. 404 is ret
|
|||
- `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`
|
||||
|
||||
|
@ -200,7 +200,7 @@ Note: Available `:permission_group` is currently moderator and admin. 404 is ret
|
|||
- `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`
|
||||
|
|
|
@ -89,9 +89,6 @@ defmodule Pleroma.User do
|
|||
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)
|
||||
|
@ -250,9 +247,6 @@ defmodule Pleroma.User do
|
|||
:settings,
|
||||
:magic_key,
|
||||
:uri,
|
||||
:topic,
|
||||
:hub,
|
||||
:salmon,
|
||||
:hide_followers_count,
|
||||
:hide_follows_count,
|
||||
:hide_followers,
|
||||
|
@ -317,9 +311,6 @@ defmodule Pleroma.User do
|
|||
:locked,
|
||||
:magic_key,
|
||||
:uri,
|
||||
:hub,
|
||||
:topic,
|
||||
:salmon,
|
||||
:hide_followers,
|
||||
:hide_follows,
|
||||
:hide_followers_count,
|
||||
|
@ -1453,7 +1444,7 @@ defmodule Pleroma.User do
|
|||
{: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),
|
||||
|
|
|
@ -51,8 +51,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
|||
:tag_users,
|
||||
:untag_users,
|
||||
:right_add,
|
||||
:right_delete,
|
||||
:set_activation_status
|
||||
:right_delete
|
||||
]
|
||||
)
|
||||
|
||||
|
@ -364,11 +363,11 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
|||
"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",
|
||||
|
@ -377,7 +376,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
|||
permission: permission_group
|
||||
})
|
||||
|
||||
json(conn, info)
|
||||
json(conn, update)
|
||||
end
|
||||
|
||||
def right_add_multiple(conn, _) do
|
||||
|
@ -429,11 +428,11 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController 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",
|
||||
|
@ -442,7 +441,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
|||
permission: permission_group
|
||||
})
|
||||
|
||||
json(conn, info)
|
||||
json(conn, update)
|
||||
else
|
||||
_ -> render_error(conn, :forbidden, "You can't revoke your own admin/moderator status.")
|
||||
end
|
||||
|
@ -481,25 +480,6 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
|||
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})
|
||||
|
@ -507,6 +487,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
|||
_ ->
|
||||
conn
|
||||
|> put_status(500)
|
||||
end
|
||||
end
|
||||
|
||||
def relay_follow(%{assigns: %{user: admin}} = conn, %{"relay_url" => target}) do
|
||||
with {:ok, _message} <- Relay.follow(target) do
|
||||
|
|
|
@ -28,9 +28,6 @@ defmodule Pleroma.Repo.Migrations.CopyUsersInfoaddsToUsers do
|
|||
:settings,
|
||||
:magic_key,
|
||||
:uri,
|
||||
:topic,
|
||||
:hub,
|
||||
:salmon,
|
||||
:hide_followers_count,
|
||||
:hide_follows_count,
|
||||
:hide_followers,
|
||||
|
@ -121,9 +118,6 @@ defmodule Pleroma.Repo.Migrations.CopyUsersInfoaddsToUsers do
|
|||
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)
|
||||
|
|
|
@ -36,8 +36,8 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
[%{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, %{
|
||||
|
@ -52,8 +52,8 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
[%{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
|
||||
|
|
|
@ -95,8 +95,8 @@ defmodule Pleroma.Web.MastodonAPI.ConversationControllerTest 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
|
||||
|
|
|
@ -108,7 +108,7 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
|
|||
[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
|
||||
|
@ -119,7 +119,7 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
|
|||
[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
|
||||
|
|
Loading…
Reference in a new issue