chore: cleanup namespace creation
continuous-integration/drone/push Build is passing Details

This commit is contained in:
kolaente 2022-03-06 17:08:58 +01:00
parent 9d816205da
commit b60c69c5a8
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 1 additions and 4 deletions

View File

@ -603,20 +603,17 @@ func (n *Namespace) ReadAll(s *xorm.Session, a web.Auth, search string, page int
// @Failure 500 {object} models.Message "Internal error"
// @Router /namespaces [put]
func (n *Namespace) Create(s *xorm.Session, a web.Auth) (err error) {
// Check if we have at least a name
// Check if we have at least a title
if n.Title == "" {
return ErrNamespaceNameCannotBeEmpty{NamespaceID: 0, UserID: a.GetID()}
}
n.ID = 0 // This would otherwise prevent the creation of new lists after one was created
// Check if the User exists
n.Owner, err = user.GetUserByID(s, a.GetID())
if err != nil {
return
}
n.OwnerID = n.Owner.ID
// Insert
if _, err = s.Insert(n); err != nil {
return err
}