Skip to content

Commit cc77780

Browse files
Channel: Add and use external_uuid as default-channel value
As the channel names are not unique, uuid should be used in GET responses
1 parent a976477 commit cc77780

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

application/controllers/ApiV1ContactsController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function (Filter\Condition $condition) {
9999
'id' => 'co.external_uuid',
100100
'full_name',
101101
'username',
102-
'default_channel' => 'ch.name',
102+
'default_channel' => 'ch.external_uuid',
103103
])
104104
->joinLeft('contact_address ca', 'ca.contact_id = co.id')
105105
->joinLeft('channel ch', 'ch.id = co.default_channel_id');

application/forms/ChannelForm.php

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use ipl\Validator\EmailAddressValidator;
1717
use ipl\Web\Common\CsrfCounterMeasure;
1818
use ipl\Web\Compat\CompatForm;
19+
use Ramsey\Uuid\Uuid;
1920

2021
/**
2122
* @phpstan-type ChannelOptionConfig array{
@@ -189,6 +190,7 @@ function ($configItem, $key) {
189190
);
190191

191192
$channel['config'] = json_encode($config);
193+
$channel['external_uuid'] = Uuid::uuid4()->toString();
192194
if ($this->channelId === null) {
193195
$this->db->insert('channel', $channel);
194196
} else {

library/Notifications/Model/Channel.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@ public function getColumns(): array
2626
return [
2727
'name',
2828
'type',
29-
'config'
29+
'config',
30+
'external_uuid'
3031
];
3132
}
3233

3334
public function getColumnDefinitions()
3435
{
3536
return [
36-
'name' => t('Name'),
37-
'type' => t('Type'),
37+
'name' => t('Name'),
38+
'type' => t('Type'),
39+
'external_uuid' => t('UUID')
3840
];
3941
}
4042

0 commit comments

Comments
 (0)