diff --git a/cmd/lists.go b/cmd/lists.go index 418b4f9..f454895 100644 --- a/cmd/lists.go +++ b/cmd/lists.go @@ -30,6 +30,14 @@ func handleGetLists(c echo.Context) error { single = true } + if single { + out, err := app.core.GetList(listID, "") + if err != nil { + return err + } + return c.JSON(http.StatusOK, okResp{out}) + } + // Minimal query simply returns the list of all lists without JOIN subscriber counts. This is fast. if !single && minimal { res, err := app.core.GetLists("") diff --git a/internal/core/lists.go b/internal/core/lists.go index 9a5f4bb..6db679e 100644 --- a/internal/core/lists.go +++ b/internal/core/lists.go @@ -82,11 +82,12 @@ func (c *Core) GetList(id int, uuid string) (models.List, error) { c.i18n.Ts("globals.messages.errorFetching", "name", "{globals.terms.lists}", "error", pqErrMsg(err))) } - if len(out) == 1 { - return out[0], nil + if len(out) == 0 { + return models.List{}, echo.NewHTTPError(http.StatusBadRequest, + c.i18n.Ts("globals.messages.notFound", "name", "{globals.terms.list}")) } - return models.List{}, nil + return out[0], nil } // GetListsByOptin returns lists by optin type.