logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/
commit: c6298be9f0a7b1a4e19248efdc39f443a24f73fd
parent de022de4ce37e2fe4ad638dfddc5e6953fd76790
Author: nicole mikołajczyk <me@mkljczk.pl>
Date:   Tue, 16 Dec 2025 20:53:32 +0100

Merge branch 'scrobbles-scope' into 'develop'

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

See merge request pleroma/pleroma!4379

Diffstat:

Achangelog.d/scrobbles-scope.change1+
Mdocs/development/API/pleroma_api.md1+
Mlib/pleroma/web/api_spec/operations/pleroma_scrobble_operation.ex4++--
Mlib/pleroma/web/pleroma_api/controllers/scrobble_controller.ex4++--
Mtest/pleroma/web/pleroma_api/controllers/scrobble_controller_test.exs4++--
5 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/changelog.d/scrobbles-scope.change b/changelog.d/scrobbles-scope.change @@ -0,0 +1 @@ +Add `write:scrobbles` and `read:scrobbles` scope for scrobbling diff --git a/docs/development/API/pleroma_api.md b/docs/development/API/pleroma_api.md @@ -684,6 +684,7 @@ Audio scrobbling in Pleroma is **deprecated**. ### Creates a new Listen activity for an account * Method `POST` * Authentication: required +* OAuth scope: `write:scrobbles` * Params: * `title`: the title of the media playing * `album`: the album of the media playing [optional] diff --git a/lib/pleroma/web/api_spec/operations/pleroma_scrobble_operation.ex b/lib/pleroma/web/api_spec/operations/pleroma_scrobble_operation.ex @@ -20,7 +20,7 @@ defmodule Pleroma.Web.ApiSpec.PleromaScrobbleOperation do %Operation{ tags: ["Scrobbles"], summary: "Creates a new Listen activity for an account", - security: [%{"oAuth" => ["write"]}], + security: [%{"oAuth" => ["write:scrobbles"]}], operationId: "PleromaAPI.ScrobbleController.create", deprecated: true, requestBody: request_body("Parameters", create_request(), required: true), @@ -39,7 +39,7 @@ defmodule Pleroma.Web.ApiSpec.PleromaScrobbleOperation do parameters: [ %Reference{"$ref": "#/components/parameters/accountIdOrNickname"} | pagination_params() ], - security: [%{"oAuth" => ["read"]}], + security: [%{"oAuth" => ["read:scrobbles"]}], responses: %{ 200 => Operation.response("Array of Scrobble", "application/json", %Schema{ diff --git a/lib/pleroma/web/pleroma_api/controllers/scrobble_controller.ex b/lib/pleroma/web/pleroma_api/controllers/scrobble_controller.ex @@ -16,10 +16,10 @@ defmodule Pleroma.Web.PleromaAPI.ScrobbleController do plug( 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 diff --git a/test/pleroma/web/pleroma_api/controllers/scrobble_controller_test.exs b/test/pleroma/web/pleroma_api/controllers/scrobble_controller_test.exs @@ -9,7 +9,7 @@ defmodule Pleroma.Web.PleromaAPI.ScrobbleControllerTest do describe "POST /api/v1/pleroma/scrobble" do test "works correctly" do - %{conn: conn} = oauth_access(["write"]) + %{conn: conn} = oauth_access(["write:scrobbles"]) conn = conn @@ -51,7 +51,7 @@ defmodule Pleroma.Web.PleromaAPI.ScrobbleControllerTest do describe "GET /api/v1/pleroma/accounts/:id/scrobbles" do test "works correctly" do - %{user: user, conn: conn} = oauth_access(["read"]) + %{user: user, conn: conn} = oauth_access(["read:scrobbles"]) {:ok, _activity} = CommonAPI.listen(user, %{