Removed 'submit' parameter

This commit is contained in:
Deluan
2016-03-16 20:45:08 -04:00
parent 4748ce142f
commit f6866f23a0
3 changed files with 7 additions and 9 deletions
+1 -1
View File
@@ -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")
+4 -6
View File
@@ -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
} }
+2 -2
View File
@@ -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)