Skip to content

Commit

Permalink
Channel: Add and use external_uuid as default-channel value
Browse files Browse the repository at this point in the history
As the channel names are not unique, uuid should be used in GET responses
  • Loading branch information
sukhwinder33445 committed Jun 27, 2024
1 parent a976477 commit cc77780
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion application/controllers/ApiV1ContactsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function (Filter\Condition $condition) {
'id' => 'co.external_uuid',
'full_name',
'username',
'default_channel' => 'ch.name',
'default_channel' => 'ch.external_uuid',
])
->joinLeft('contact_address ca', 'ca.contact_id = co.id')
->joinLeft('channel ch', 'ch.id = co.default_channel_id');
Expand Down
2 changes: 2 additions & 0 deletions application/forms/ChannelForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use ipl\Validator\EmailAddressValidator;
use ipl\Web\Common\CsrfCounterMeasure;
use ipl\Web\Compat\CompatForm;
use Ramsey\Uuid\Uuid;

/**
* @phpstan-type ChannelOptionConfig array{
Expand Down Expand Up @@ -189,6 +190,7 @@ function ($configItem, $key) {
);

$channel['config'] = json_encode($config);
$channel['external_uuid'] = Uuid::uuid4()->toString();
if ($this->channelId === null) {
$this->db->insert('channel', $channel);
} else {
Expand Down
8 changes: 5 additions & 3 deletions library/Notifications/Model/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ public function getColumns(): array
return [
'name',
'type',
'config'
'config',
'external_uuid'
];
}

public function getColumnDefinitions()
{
return [
'name' => t('Name'),
'type' => t('Type'),
'name' => t('Name'),
'type' => t('Type'),
'external_uuid' => t('UUID')
];
}

Expand Down

0 comments on commit cc77780

Please sign in to comment.