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

View File

@ -24,7 +24,7 @@ func (c *MediaAnnotationController) Scrobble() {
time := c.ParamTime("time", time.Now())
submission := c.ParamBool("submission", false)
if submission {
mf, err := c.scrobbler.Register(id, time, true)
mf, err := c.scrobbler.Register(id, time)
if err != nil {
beego.Error("Error scrobbling:", err)
c.SendError(responses.ERROR_GENERIC, "Internal error")

View File

@ -10,7 +10,7 @@ import (
)
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 {
@ -23,7 +23,7 @@ type scrobbler struct {
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)
if err != nil {
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))
}
if submit {
if err := s.itunes.MarkAsPlayed(id, playDate); err != nil {
return nil, err
}
if err := s.itunes.MarkAsPlayed(id, playDate); err != nil {
return nil, err
}
return mf, nil
}

View File

@ -27,7 +27,7 @@ func TestScrobbler(t *testing.T) {
Convey("When I scrobble an existing song", func() {
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() {
So(err, ShouldBeNil)
@ -42,7 +42,7 @@ func TestScrobbler(t *testing.T) {
})
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() {
So(err, ShouldNotBeNil)