Skip to content

Commit

Permalink
ApiV1ContactsController: Only update contact.username on PUT if s…
Browse files Browse the repository at this point in the history
…pecified
  • Loading branch information
sukhwinder33445 committed Jun 14, 2024
1 parent b8959cc commit 8c45754
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions application/controllers/ApiV1ContactsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down

0 comments on commit 8c45754

Please sign in to comment.