diff --git a/src/app/contact/controllers/ContactGroupController.php b/src/app/contact/controllers/ContactGroupController.php index 33fb84caf20346a45ea51f6a48869a7e6dd1f748..a633899810a30689053d39fbd0eac68166c584cf 100644 --- a/src/app/contact/controllers/ContactGroupController.php +++ b/src/app/contact/controllers/ContactGroupController.php @@ -112,6 +112,12 @@ class ContactGroupController return $response->withStatus(400)->withJson(['errors' => 'Bad Request']); } + $user = UserModel::getByUserId(['select' => ['id'], 'userId' => $GLOBALS['userId']]); + $existingGroup = ContactGroupModel::get(['select' => [1], 'where' => ['label = ?', 'owner = ?'], 'data' => [$data['label'], $user['id']]]); + if (!empty($existingGroup)) { + return $response->withStatus(400)->withJson(['errors' => _CONTACTS_GROUP_LABEL_ALREADY_EXISTS]); + } + $data['id'] = $aArgs['id']; $data['public'] = $data['public'] ? 'true' : 'false';