navidrome/plugins/host
Kendall Garner b0c6d2e444
feat(plugins): add scrobbles access to PDK (#5795)
* initial scrobble api

* feat: add scrobble retrieval api

* address feedback (1)

* fix spelling

* be explicit about get

* add primary key field, update index, remove rowid references

* use unix timestamp for input and output

* initial api, some testing

* add tests, add count retrieval

* add docs, test for rejected user

* add permission validation for scrobble retriever

* chore(plugins): fix typos in scrobble retriever

Rename newScrobbleRetreverService, and fix FromTImestamp/nonero in the
ScrobbleRetriever doc comments, which generate into the Go and Rust PDKs.
Also corrects two mislabelled test entries.

* fix(plugins): make scrobble pagination order deterministic

Sorting only by submission_time left the order of equal timestamps up to the
query planner, but the cursor skips ties by offset, so an unstable order can
repeat or drop scrobbles between pages. Break ties on scrobbles.id, which the
existing scrobbles_user_time index already yields for free.

Descending is now honoured for every combination of From/To rather than only
when both or neither is set. This changes the default for a lone ToTimestamp
from newest-first to oldest-first.

* refactor(plugins): return the next page's options from GetScrobbles

Paging previously meant reading NextTimestamp and Cursor off the response and
deciding where each belonged: NextTimestamp into FromTimestamp when ascending
or ToTimestamp when descending, and Cursor copied every time, including when 0.
Both are silent data-loss bugs when a plugin gets them wrong.

GetScrobbles now returns the options for the following page, or nil when the
range is exhausted, so a plugin passes the value straight back and repeats.
ScrobbleCursor and ScrobbleList are gone; the query itself is unchanged.

* docs(plugins): warn against setting ScrobbleOptions.Offset manually

The all-ties carry rule assumes Offset counts already-returned rows at the
boundary timestamp, which only holds for the options GetScrobbles returns.
A hand-built From+Offset combination can silently skip scrobbles, so document
the field as managed pagination state instead of a generic skip.

* docs(plugins): document the ScrobbleRetriever host service in the README

Covers the manifest permissions (including the users requirement), the four
host functions, the options/ref field tables, and the pagination loop with
its two gotchas: the host-managed offset and the adjusted range on the
returned next options.

* chore(plugins): regenerate scrobble retriever stub with nil-safe accessors

---------

Co-authored-by: Deluan Quintão <deluan@navidrome.org>
2026-08-08 22:13:29 -04:00
..
artwork.go feat(plugins): New Plugin System with multi-language PDK support (#4833) 2026-01-14 19:22:48 -05:00
artwork_gen.go feat(plugins): New Plugin System with multi-language PDK support (#4833) 2026-01-14 19:22:48 -05:00
cache.go feat(plugins): New Plugin System with multi-language PDK support (#4833) 2026-01-14 19:22:48 -05:00
cache_gen.go feat(plugins): New Plugin System with multi-language PDK support (#4833) 2026-01-14 19:22:48 -05:00
config.go feat(plugins): New Plugin System with multi-language PDK support (#4833) 2026-01-14 19:22:48 -05:00
config_gen.go feat(plugins): New Plugin System with multi-language PDK support (#4833) 2026-01-14 19:22:48 -05:00
doc.go feat(plugins): New Plugin System with multi-language PDK support (#4833) 2026-01-14 19:22:48 -05:00
http.go feat(plugins): add NoFollowRedirects option to HTTPRequest 2026-03-20 18:16:07 -04:00
http_gen.go refactor(http): rename HTTP client files and update struct names for consistency 2026-02-26 16:19:37 -05:00
kvstore.go feat(plugins): add TTL support, batch operations, and hardening to kvstore (#5127) 2026-02-28 23:12:17 -05:00
kvstore_gen.go feat(plugins): add TTL support, batch operations, and hardening to kvstore (#5127) 2026-02-28 23:12:17 -05:00
library.go feat(plugins): New Plugin System with multi-language PDK support (#4833) 2026-01-14 19:22:48 -05:00
library_gen.go feat(plugins): New Plugin System with multi-language PDK support (#4833) 2026-01-14 19:22:48 -05:00
matcher.go feat(plugins): expose the song Matcher as a host service (#5643) 2026-07-01 11:19:15 -04:00
matcher_gen.go feat(plugins): expose the song Matcher as a host service (#5643) 2026-07-01 11:19:15 -04:00
scheduler.go feat(plugins): New Plugin System with multi-language PDK support (#4833) 2026-01-14 19:22:48 -05:00
scheduler_gen.go feat(plugins): New Plugin System with multi-language PDK support (#4833) 2026-01-14 19:22:48 -05:00
scrobble_retriever.go feat(plugins): add scrobbles access to PDK (#5795) 2026-08-08 22:13:29 -04:00
scrobbleretriever_gen.go feat(plugins): add scrobbles access to PDK (#5795) 2026-08-08 22:13:29 -04:00
storage.go feat(plugins): implement plugin specific storage (#5839) 2026-08-03 14:23:42 -04:00
storage_gen.go feat(plugins): implement plugin specific storage (#5839) 2026-08-03 14:23:42 -04:00
subsonicapi.go fix(plugins): add base64 handling for []byte and remove raw=true (#5121) 2026-02-27 19:00:19 -05:00
subsonicapi_gen.go fix(plugins): add base64 handling for []byte and remove raw=true (#5121) 2026-02-27 19:00:19 -05:00
task.go feat(plugins): add TaskQueue host service for persistent background task queues (#5116) 2026-03-03 13:48:49 -05:00
task_gen.go feat(plugins): add TaskQueue host service for persistent background task queues (#5116) 2026-03-03 13:48:49 -05:00
users.go feat(plugins): New Plugin System with multi-language PDK support (#4833) 2026-01-14 19:22:48 -05:00
users_gen.go feat(plugins): New Plugin System with multi-language PDK support (#4833) 2026-01-14 19:22:48 -05:00
websocket.go feat(plugins): New Plugin System with multi-language PDK support (#4833) 2026-01-14 19:22:48 -05:00
websocket_gen.go feat(plugins): New Plugin System with multi-language PDK support (#4833) 2026-01-14 19:22:48 -05:00