Skip to content

Commit 8c45754

Browse files
ApiV1ContactsController: Only update contact.username on PUT if specified
1 parent b8959cc commit 8c45754

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

application/controllers/ApiV1ContactsController.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,16 @@ function (Filter\Condition $condition) {
221221

222222
$contactId = $this->getContactId($identifier);
223223
if ($contactId !== null) {
224-
$db->update('contact', [
224+
$toUpdate = [
225225
'full_name' => $data['full_name'],
226-
'username' => $data['username'] ?? null,
227226
'default_channel_id' => $this->getChannelId($data['default_channel'])
228-
], ['id = ?' => $contactId]);
227+
];
228+
229+
if (! empty($data['username'])) {
230+
$toUpdate['username'] = $data['username'];
231+
}
232+
233+
$db->update('contact', $toUpdate, ['id = ?' => $contactId]);
229234

230235
$db->delete('contact_address', ['contact_id = ?' => $contactId]);
231236
$db->delete('contactgroup_member', ['contact_id = ?' => $contactId]);

0 commit comments

Comments
 (0)