Merge branch 'scrobbles-scope' into 'develop'

Add `write:scrobbles` and `read:scrobbles` scope for scrobbling

See merge request pleroma/pleroma!4379
This commit is contained in:
nicole mikołajczyk 2025-12-16 20:53:32 +01:00
commit c6298be9f0
5 changed files with 8 additions and 6 deletions

View file

@ -0,0 +1 @@
Add `write:scrobbles` and `read:scrobbles` scope for scrobbling

View file

@ -684,6 +684,7 @@ Audio scrobbling in Pleroma is **deprecated**.
### Creates a new Listen activity for an account ### Creates a new Listen activity for an account
* Method `POST` * Method `POST`
* Authentication: required * Authentication: required
* OAuth scope: `write:scrobbles`
* Params: * Params:
* `title`: the title of the media playing * `title`: the title of the media playing
* `album`: the album of the media playing [optional] * `album`: the album of the media playing [optional]

View file

@ -20,7 +20,7 @@ defmodule Pleroma.Web.ApiSpec.PleromaScrobbleOperation do
%Operation{ %Operation{
tags: ["Scrobbles"], tags: ["Scrobbles"],
summary: "Creates a new Listen activity for an account", summary: "Creates a new Listen activity for an account",
security: [%{"oAuth" => ["write"]}], security: [%{"oAuth" => ["write:scrobbles"]}],
operationId: "PleromaAPI.ScrobbleController.create", operationId: "PleromaAPI.ScrobbleController.create",
deprecated: true, deprecated: true,
requestBody: request_body("Parameters", create_request(), required: true), requestBody: request_body("Parameters", create_request(), required: true),
@ -39,7 +39,7 @@ defmodule Pleroma.Web.ApiSpec.PleromaScrobbleOperation do
parameters: [ parameters: [
%Reference{"$ref": "#/components/parameters/accountIdOrNickname"} | pagination_params() %Reference{"$ref": "#/components/parameters/accountIdOrNickname"} | pagination_params()
], ],
security: [%{"oAuth" => ["read"]}], security: [%{"oAuth" => ["read:scrobbles"]}],
responses: %{ responses: %{
200 => 200 =>
Operation.response("Array of Scrobble", "application/json", %Schema{ Operation.response("Array of Scrobble", "application/json", %Schema{

View file

@ -16,10 +16,10 @@ defmodule Pleroma.Web.PleromaAPI.ScrobbleController do
plug( plug(
OAuthScopesPlug, OAuthScopesPlug,
%{scopes: ["read"], fallback: :proceed_unauthenticated} when action == :index %{scopes: ["read:scrobbles"], fallback: :proceed_unauthenticated} when action == :index
) )
plug(OAuthScopesPlug, %{scopes: ["write"]} when action == :create) plug(OAuthScopesPlug, %{scopes: ["write:scrobbles"]} when action == :create)
defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.PleromaScrobbleOperation defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.PleromaScrobbleOperation

View file

@ -9,7 +9,7 @@ defmodule Pleroma.Web.PleromaAPI.ScrobbleControllerTest do
describe "POST /api/v1/pleroma/scrobble" do describe "POST /api/v1/pleroma/scrobble" do
test "works correctly" do test "works correctly" do
%{conn: conn} = oauth_access(["write"]) %{conn: conn} = oauth_access(["write:scrobbles"])
conn = conn =
conn conn
@ -51,7 +51,7 @@ defmodule Pleroma.Web.PleromaAPI.ScrobbleControllerTest do
describe "GET /api/v1/pleroma/accounts/:id/scrobbles" do describe "GET /api/v1/pleroma/accounts/:id/scrobbles" do
test "works correctly" do test "works correctly" do
%{user: user, conn: conn} = oauth_access(["read"]) %{user: user, conn: conn} = oauth_access(["read:scrobbles"])
{:ok, _activity} = {:ok, _activity} =
CommonAPI.listen(user, %{ CommonAPI.listen(user, %{