diff --git a/internal/goscrobble/album.go b/internal/goscrobble/album.go index 2618549a..e77d3b80 100644 --- a/internal/goscrobble/album.go +++ b/internal/goscrobble/album.go @@ -28,7 +28,10 @@ func insertAlbum(name string, mbid string, artists []string, tx *sql.Tx) (Album, } album = fetchAlbum("mbid", mbid, tx) - album.linkAlbumToArtists(artists, tx) + err = album.linkAlbumToArtists(artists, tx) + if err != nil { + return album, err + } } } else { album = fetchAlbum("name", name, tx) @@ -40,7 +43,10 @@ func insertAlbum(name string, mbid string, artists []string, tx *sql.Tx) (Album, } album = fetchAlbum("name", name, tx) - album.linkAlbumToArtists(artists, tx) + err = album.linkAlbumToArtists(artists, tx) + if err != nil { + return album, err + } } } @@ -76,8 +82,8 @@ func insertNewAlbum(name string, mbid string, tx *sql.Tx) error { func (album *Album) linkAlbumToArtists(artists []string, tx *sql.Tx) error { var err error for _, artist := range artists { - _, err = tx.Exec("INSERT INTO `track_artist` (`track`, `artist`) "+ - "VALUES (UUID_TO_BIN(?, true), UUID_TO_BIN(?, true)", album.Uuid, artist) + _, err = tx.Exec("INSERT INTO `album_artist` (`album`, `artist`) "+ + "VALUES (UUID_TO_BIN(?, true), UUID_TO_BIN(?, true))", album.Uuid, artist) if err != nil { return err } diff --git a/internal/goscrobble/server.go b/internal/goscrobble/server.go index 5627f912..5e08cdd1 100644 --- a/internal/goscrobble/server.go +++ b/internal/goscrobble/server.go @@ -97,10 +97,10 @@ func throwBadReq(w http.ResponseWriter, m string) { http.Error(w, err.Error(), http.StatusBadRequest) } -// throwUnauthorized - Throws a 403 +// throwOkMessage - Throws a happy 200 func throwOkMessage(w http.ResponseWriter, m string) { jr := jsonResponse{ - Err: m, + Msg: m, } js, _ := json.Marshal(&jr) err := errors.New(string(js)) @@ -241,11 +241,11 @@ func handleIngress(w http.ResponseWriter, r *http.Request) { return } - throwOkMessage(w, "{}") + throwOkMessage(w, "success") return } - // Lets trick 'em for now ;) ;) - fmt.Fprintf(w, "{}") + + throwBadReq(w, "Unknown ingress type") } // FRONTEND HANDLING