[#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:
Ivan Tashkinov 2019-10-20 22:29:56 +03:00
parent c6fdfbc4f1
commit ee04fbc35a
7 changed files with 20 additions and 53 deletions

View File

@ -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`

View File

@ -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 @@ def following_count(%User{} = user) do
:settings,
:magic_key,
:uri,
:topic,
:hub,
:salmon,
:hide_followers_count,
:hide_follows_count,
:hide_followers,
@ -317,9 +311,6 @@ def remote_user_creation(params) do
:locked,
:magic_key,
:uri,
:hub,
:topic,
:salmon,
:hide_followers,
:hide_follows,
:hide_followers_count,
@ -1453,7 +1444,7 @@ def public_key(%{source_data: %{"publicKey" => %{"publicKeyPem" => public_key_pe
{: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),

View File

@ -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 @@ def right_add_multiple(%{assigns: %{user: admin}} = conn, %{
"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 @@ def right_add_multiple(%{assigns: %{user: admin}} = conn, %{
permission: permission_group
})
json(conn, info)
json(conn, update)
end
def right_add_multiple(conn, _) do
@ -429,11 +428,11 @@ def right_delete_multiple(
)
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 @@ def right_delete_multiple(
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 @@ def right_delete(%{assigns: %{user: %{nickname: nickname}}} = conn, %{"nickname"
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 @@ def relay_list(conn, _params) 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

View File

@ -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 @@ def change 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)

View File

@ -36,8 +36,8 @@ test "for a new conversation or a reply, it doesn't mark the author's participat
[%{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 @@ test "for a new conversation or a reply, it doesn't mark the author's participat
[%{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

View File

@ -95,8 +95,8 @@ test "the user marks a conversation as read", %{conn: conn} 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

View File

@ -108,7 +108,7 @@ test "POST /api/v1/pleroma/conversations/read", %{conn: conn} 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 @@ test "POST /api/v1/pleroma/conversations/read", %{conn: conn} 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