Fix broken single list fetch API.
This commit is contained in:
parent
e60b38527c
commit
8d4a5751d8
2 changed files with 12 additions and 3 deletions
|
@ -30,6 +30,14 @@ func handleGetLists(c echo.Context) error {
|
||||||
single = true
|
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.
|
// Minimal query simply returns the list of all lists without JOIN subscriber counts. This is fast.
|
||||||
if !single && minimal {
|
if !single && minimal {
|
||||||
res, err := app.core.GetLists("")
|
res, err := app.core.GetLists("")
|
||||||
|
|
|
@ -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)))
|
c.i18n.Ts("globals.messages.errorFetching", "name", "{globals.terms.lists}", "error", pqErrMsg(err)))
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(out) == 1 {
|
if len(out) == 0 {
|
||||||
return out[0], nil
|
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.
|
// GetListsByOptin returns lists by optin type.
|
||||||
|
|
Loading…
Reference in a new issue