diff options
author | Christian Pointner <equinox@helsinki.at> | 2015-12-13 04:02:43 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2015-12-13 04:02:43 (GMT) |
commit | e9ffae4f5f6858a3736136009aff87cb9369a4c1 (patch) | |
tree | ed1bf33d5e1336e08ae6381c6e30da95af01383c /src/helsinki.at/rhimport/importer.go | |
parent | 60666c71b666026697f7cfd3e92607e6dc4df67c (diff) |
music pool group check works now
Diffstat (limited to 'src/helsinki.at/rhimport/importer.go')
-rw-r--r-- | src/helsinki.at/rhimport/importer.go | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/helsinki.at/rhimport/importer.go b/src/helsinki.at/rhimport/importer.go index 95f61f7..8206082 100644 --- a/src/helsinki.at/rhimport/importer.go +++ b/src/helsinki.at/rhimport/importer.go @@ -97,7 +97,13 @@ func (ctx *ImportContext) SanityCheck() error { return nil } if ctx.GroupName != "" { - // TODO: check if GroupName is a music pool -> Error if not + ismusic, err := ctx.checkMusicGroup() + if err != nil { + return err + } + if !ismusic { + return fmt.Errorf("supplied GroupName is not a music pool") + } return nil } if ctx.Cart == 0 { @@ -118,14 +124,13 @@ func (ctx *ImportContext) getPassword(cached bool) (err error) { res := <-req.response if res.err != nil { - err = res.err - return + return res.err } ctx.Password = res.password - return + return nil } -func (ctx *ImportContext) getGroupOfCart() (err error) { +func (ctx *ImportContext) getGroupOfCart() error { req := getGroupOfCartRequest{} req.cart = ctx.Cart req.response = make(chan getGroupOfCartResult) @@ -133,11 +138,10 @@ func (ctx *ImportContext) getGroupOfCart() (err error) { res := <-req.response if res.err != nil { - err = res.err - return + return res.err } ctx.GroupName = res.group - return + return nil } func (ctx *ImportContext) getShowInfo() (err error) { @@ -155,6 +159,19 @@ func (ctx *ImportContext) getShowInfo() (err error) { return } +func (ctx *ImportContext) checkMusicGroup() (bool, error) { + req := checkMusicGroupRequest{} + req.group = ctx.GroupName + req.response = make(chan checkMusicGroupResult) + ctx.RdDb.checkMusicGroupChan <- req + + res := <-req.response + if res.err != nil { + return false, res.err + } + return res.ismusic, nil +} + type ImportResult struct { ResponseCode int ErrorString string |