@@ -24,7 +24,7 @@ func NewPlaylistTableInstance() IPlaylistTable {
2424}
2525
2626func (table * PlaylistTable ) FetchPlaylists (ctx context.Context , lastKnowPlaylistId int ) (playlists []models.Playlist , error error ) {
27- query := "SELECT Id, Name, ThumbnailPath, Description, CreationDate FROM Playlist WHERE Id > $1 ORDER BY Id" // order by?
27+ query := "SELECT Id, Name, ThumbnailPath, Description, CreationDate, IsPublic FROM Playlist WHERE Id > $1 ORDER BY Id" // order by?
2828
2929 rows , err := table .QueryRowsContex (ctx , query , lastKnowPlaylistId )
3030
@@ -41,7 +41,7 @@ func (table *PlaylistTable) FetchPlaylists(ctx context.Context, lastKnowPlaylist
4141 playlists = make ([]models.Playlist , 0 )
4242
4343 for rows .Next () {
44- scanError := rows .Scan (& playlist .Id , & playlist .Name , & playlist .ThumbnailPath , & playlist .Description , & playlist .CreationDate )
44+ scanError := rows .Scan (& playlist .Id , & playlist .Name , & playlist .ThumbnailPath , & playlist .Description , & playlist .CreationDate , & playlist . IsPublic )
4545
4646 if scanError != nil {
4747 logging .Error (fmt .Sprintf ("Scan error: %s" , scanError .Error ()))
@@ -68,9 +68,9 @@ func (table *PlaylistTable) InsertPlaylist(playlist models.Playlist) (lastInsert
6868}
6969
7070func (table * PlaylistTable ) DeletePlaylist (playlistId int ) (error error ) {
71- query := `DELETE FROM Playlist WHERE Id = $1`
71+ query := `DELETE FROM Playlist WHERE Id = $1 AND IsPublic = $2` // Prevemts private playlists (like the default one) from being deleted for real
7272
73- err := table .NonScalarQuery (query , playlistId )
73+ err := table .NonScalarQuery (query , playlistId , true )
7474
7575 if err != nil {
7676 logging .Error (fmt .Sprintf ("Failed to delete playlist: %s" , err .Error ()))
0 commit comments