added unread_notifications_count for /api/v1/accounts/verify_credentials
This commit is contained in:
parent
8b97b6f5ba
commit
bd261309cc
5 changed files with 55 additions and 4 deletions
|
|
@ -1196,12 +1196,15 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
describe "verify_credentials" do
|
||||
test "verify_credentials" do
|
||||
%{user: user, conn: conn} = oauth_access(["read:accounts"])
|
||||
[notification | _] = insert_list(7, :notification, user: user)
|
||||
Pleroma.Notification.set_read_up_to(user, notification.id)
|
||||
conn = get(conn, "/api/v1/accounts/verify_credentials")
|
||||
|
||||
response = json_response_and_validate_schema(conn, 200)
|
||||
|
||||
assert %{"id" => id, "source" => %{"privacy" => "public"}} = response
|
||||
assert response["pleroma"]["chat_token"]
|
||||
assert response["pleroma"]["unread_notifications_count"] == 6
|
||||
assert id == to_string(user.id)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -466,6 +466,24 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
:unread_conversation_count
|
||||
] == 1
|
||||
end
|
||||
|
||||
test "shows unread_count only to the account owner" do
|
||||
user = insert(:user)
|
||||
insert_list(7, :notification, user: user)
|
||||
other_user = insert(:user)
|
||||
|
||||
user = User.get_cached_by_ap_id(user.ap_id)
|
||||
|
||||
assert AccountView.render(
|
||||
"show.json",
|
||||
%{user: user, for: other_user}
|
||||
)[:pleroma][:unread_notifications_count] == nil
|
||||
|
||||
assert AccountView.render(
|
||||
"show.json",
|
||||
%{user: user, for: user}
|
||||
)[:pleroma][:unread_notifications_count] == 7
|
||||
end
|
||||
end
|
||||
|
||||
describe "follow requests counter" do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue