feat: favourites of songs, albums and artists, in the API and in apps
A person can mark songs, albums and artists as favourites. They are theirs
alone: never shown to a friend, never sent anywhere. Only what can be played is
listed.
- migration 0035 favorites, internal/favorites, storage.FavoritesRepo
- PUT/DELETE /me/favorites/{kind}/{id}, GET /me/favorites/{kind} and
GET /me/favorites/ids, in the OpenAPI spec
- catalog.Filter IDs now also reads artists by id
- OpenSubsonic: star, unstar, getStarred2, the starred date on songs, albums and
artists, and getAlbumList2 of type starred
This commit is contained in:
parent
17c134ef8b
commit
74f683d26e
2 changed files with 1676 additions and 42 deletions
12
migrations/postgres/0035_favorites.sql
Normal file
12
migrations/postgres/0035_favorites.sql
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
-- The songs, albums and artists a person marked as favourites. There is no foreign key on the item (it is in one of
|
||||
-- three tables): a favourite whose item is gone is ignored when read.
|
||||
|
||||
CREATE TABLE favorites (
|
||||
user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
kind TEXT NOT NULL CHECK (kind IN ('artist', 'album', 'track')),
|
||||
item_id BIGINT NOT NULL,
|
||||
created_at BIGINT NOT NULL,
|
||||
PRIMARY KEY (user_id, kind, item_id)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_favorites_time ON favorites(user_id, kind, created_at DESC);
|
||||
12
migrations/sqlite/0035_favorites.sql
Normal file
12
migrations/sqlite/0035_favorites.sql
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
-- The songs, albums and artists a person marked as favourites. There is no foreign key on the item (it is in one of
|
||||
-- three tables): a favourite whose item is gone is ignored when read.
|
||||
|
||||
CREATE TABLE favorites (
|
||||
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
kind TEXT NOT NULL CHECK (kind IN ('artist', 'album', 'track')),
|
||||
item_id INTEGER NOT NULL,
|
||||
created_at INTEGER NOT NULL, -- unix seconds
|
||||
PRIMARY KEY (user_id, kind, item_id)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_favorites_time ON favorites(user_id, kind, created_at DESC);
|
||||
Loading…
Reference in a new issue