diff --git a/application/controllers/ApiV1ContactsController.php b/application/controllers/ApiV1ContactsController.php index 90cc9d85a..7e08f1bd3 100644 --- a/application/controllers/ApiV1ContactsController.php +++ b/application/controllers/ApiV1ContactsController.php @@ -221,11 +221,16 @@ function (Filter\Condition $condition) { $contactId = $this->getContactId($identifier); if ($contactId !== null) { - $db->update('contact', [ + $toUpdate = [ 'full_name' => $data['full_name'], - 'username' => $data['username'] ?? null, 'default_channel_id' => $this->getChannelId($data['default_channel']) - ], ['id = ?' => $contactId]); + ]; + + if (! empty($data['username'])) { + $toUpdate['username'] = $data['username']; + } + + $db->update('contact', $toUpdate, ['id = ?' => $contactId]); $db->delete('contact_address', ['contact_id = ?' => $contactId]); $db->delete('contactgroup_member', ['contact_id = ?' => $contactId]);