feat(settings): my own settings, starting with Discover from my listening

- GET and PATCH /me/settings: settings that belong to the signed-in user.
- First setting, discover_from_listening, is off by default. When on, Discover
  may start from the artists I listen to most, which sends their names to
  Last.fm.
- New user_settings table (migration 0011, SQLite and PostgreSQL), removed with
  the account. A user with no row has the private defaults.
- A misspelt setting is rejected instead of being ignored.
- Spec, contract test and README updated.

Refs #29
This commit is contained in:
tgiachi 2026-11-11 19:16:26 +01:00
commit e0592c0260
2 changed files with 514 additions and 4 deletions

View file

@ -0,0 +1,10 @@
-- Settings that belong to one user. A user with no row has the defaults, which are
-- the private ones: everything that sends something to a provider is off.
--
-- discover_from_listening: Discover may start from the artists the user listens to
-- most, which sends their names to Last.fm to ask for similar artists.
CREATE TABLE user_settings (
user_id BIGINT PRIMARY KEY REFERENCES users(id) ON DELETE CASCADE,
discover_from_listening BOOLEAN NOT NULL DEFAULT FALSE
);

View file

@ -0,0 +1,10 @@
-- Settings that belong to one user. A user with no row has the defaults, which are
-- the private ones: everything that sends something to a provider is off.
--
-- discover_from_listening: Discover may start from the artists the user listens to
-- most, which sends their names to Last.fm to ask for similar artists.
CREATE TABLE user_settings (
user_id INTEGER PRIMARY KEY REFERENCES users(id) ON DELETE CASCADE,
discover_from_listening INTEGER NOT NULL DEFAULT 0 CHECK (discover_from_listening IN (0, 1))
);