Removed 'submit' parameter
This commit is contained in:
@@ -24,7 +24,7 @@ func (c *MediaAnnotationController) Scrobble() {
|
|||||||
time := c.ParamTime("time", time.Now())
|
time := c.ParamTime("time", time.Now())
|
||||||
submission := c.ParamBool("submission", false)
|
submission := c.ParamBool("submission", false)
|
||||||
if submission {
|
if submission {
|
||||||
mf, err := c.scrobbler.Register(id, time, true)
|
mf, err := c.scrobbler.Register(id, time)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
beego.Error("Error scrobbling:", err)
|
beego.Error("Error scrobbling:", err)
|
||||||
c.SendError(responses.ERROR_GENERIC, "Internal error")
|
c.SendError(responses.ERROR_GENERIC, "Internal error")
|
||||||
|
|||||||
+2
-4
@@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Scrobbler interface {
|
type Scrobbler interface {
|
||||||
Register(id string, playDate time.Time, submit bool) (*domain.MediaFile, error)
|
Register(id string, playDate time.Time) (*domain.MediaFile, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewScrobbler(itunes itunesbridge.ItunesControl, mr domain.MediaFileRepository, npr NowPlayingRepository) Scrobbler {
|
func NewScrobbler(itunes itunesbridge.ItunesControl, mr domain.MediaFileRepository, npr NowPlayingRepository) Scrobbler {
|
||||||
@@ -23,7 +23,7 @@ type scrobbler struct {
|
|||||||
npRepo NowPlayingRepository
|
npRepo NowPlayingRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s scrobbler) Register(id string, playDate time.Time, submit bool) (*domain.MediaFile, error) {
|
func (s scrobbler) Register(id string, playDate time.Time) (*domain.MediaFile, error) {
|
||||||
mf, err := s.mfRepo.Get(id)
|
mf, err := s.mfRepo.Get(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -33,10 +33,8 @@ func (s scrobbler) Register(id string, playDate time.Time, submit bool) (*domain
|
|||||||
return nil, errors.New(fmt.Sprintf(`Id "%s" not found`, id))
|
return nil, errors.New(fmt.Sprintf(`Id "%s" not found`, id))
|
||||||
}
|
}
|
||||||
|
|
||||||
if submit {
|
|
||||||
if err := s.itunes.MarkAsPlayed(id, playDate); err != nil {
|
if err := s.itunes.MarkAsPlayed(id, playDate); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return mf, nil
|
return mf, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func TestScrobbler(t *testing.T) {
|
|||||||
|
|
||||||
Convey("When I scrobble an existing song", func() {
|
Convey("When I scrobble an existing song", func() {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
mf, err := scrobbler.Register("2", now, true)
|
mf, err := scrobbler.Register("2", now)
|
||||||
|
|
||||||
Convey("Then I get the scrobbled song back", func() {
|
Convey("Then I get the scrobbled song back", func() {
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
@@ -42,7 +42,7 @@ func TestScrobbler(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Convey("When the ID is not in the DB", func() {
|
Convey("When the ID is not in the DB", func() {
|
||||||
_, err := scrobbler.Register("3", time.Now(), true)
|
_, err := scrobbler.Register("3", time.Now())
|
||||||
|
|
||||||
Convey("Then I receive an error", func() {
|
Convey("Then I receive an error", func() {
|
||||||
So(err, ShouldNotBeNil)
|
So(err, ShouldNotBeNil)
|
||||||
|
|||||||
Reference in New Issue
Block a user