Skip to content

Commit 1a0c58e

Browse files
authored
Merge pull request #1372 from it-at-m/bugfix-zmskvr-615-expiry-of-blocked-time
fix(ZMSKVR-615): notification of session timeout
2 parents c0910e9 + 750c6ea commit 1a0c58e

27 files changed

+428
-259
lines changed

phpmd.rules.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
<rule ref="rulesets/codesize.xml/ExcessiveParameterList">
5252
<properties>
53-
<property name="minimum" value="20" />
53+
<property name="minimum" value="25" />
5454
</properties>
5555
</rule>
5656

zmsadmin/package-lock.json

Lines changed: 4 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

zmscitizenapi/src/Zmscitizenapi/Models/ThinnedScope.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ class ThinnedScope extends Entity implements JsonSerializable
3131
public ?string $slotsPerAppointment;
3232
public ?string $appointmentsPerMail;
3333
public ?string $whitelistedMails;
34+
public ?int $reservationDuration = null;
3435

35-
public function __construct(int $id = 0, ?ThinnedProvider $provider = null, ?string $shortName = null, ?string $emailFrom = null, ?bool $emailRequired = null, ?bool $telephoneActivated = null, ?bool $telephoneRequired = null, ?bool $customTextfieldActivated = null, ?bool $customTextfieldRequired = null, ?string $customTextfieldLabel = null, ?bool $customTextfield2Activated = null, ?bool $customTextfield2Required = null, ?string $customTextfield2Label = null, ?bool $captchaActivatedRequired = null, ?string $infoForAppointment = null, ?string $infoForAllAppointments = null, ?string $slotsPerAppointment = null, ?string $appointmentsPerMail = null, ?string $whitelistedMails = null)
36+
public function __construct(int $id = 0, ?ThinnedProvider $provider = null, ?string $shortName = null, ?string $emailFrom = null, ?bool $emailRequired = null, ?bool $telephoneActivated = null, ?bool $telephoneRequired = null, ?bool $customTextfieldActivated = null, ?bool $customTextfieldRequired = null, ?string $customTextfieldLabel = null, ?bool $customTextfield2Activated = null, ?bool $customTextfield2Required = null, ?string $customTextfield2Label = null, ?bool $captchaActivatedRequired = null, ?string $infoForAppointment = null, ?string $infoForAllAppointments = null, ?string $slotsPerAppointment = null, ?string $appointmentsPerMail = null, ?string $whitelistedMails = null, ?int $reservationDuration = null)
3637
{
3738
$this->id = $id;
3839
$this->provider = $provider;
@@ -53,6 +54,7 @@ public function __construct(int $id = 0, ?ThinnedProvider $provider = null, ?str
5354
$this->slotsPerAppointment = $slotsPerAppointment;
5455
$this->appointmentsPerMail = $appointmentsPerMail;
5556
$this->whitelistedMails = $whitelistedMails;
57+
$this->reservationDuration = $reservationDuration;
5658
$this->ensureValid();
5759
}
5860

@@ -153,6 +155,11 @@ public function getWhitelistedMails(): ?string
153155
return $this->whitelistedMails;
154156
}
155157

158+
public function getReservationDuration(): ?int
159+
{
160+
return $this->reservationDuration;
161+
}
162+
156163
public function toArray(): array
157164
{
158165
return [
@@ -175,6 +182,7 @@ public function toArray(): array
175182
'slotsPerAppointment' => $this->slotsPerAppointment,
176183
'appointmentsPerMail' => $this->appointmentsPerMail,
177184
'whitelistedMails' => $this->whitelistedMails,
185+
'reservationDuration' => $this->reservationDuration,
178186
];
179187
}
180188

zmscitizenapi/src/Zmscitizenapi/Services/Core/MapperService.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ public static function mapScopeForProvider(int $providerId, ?ThinnedScopeList $s
5151
return $matchingScope;
5252
}
5353

54+
public static function extractReservationDuration(Scope|ThinnedScope|null $scope): ?int
55+
{
56+
if ($scope === null) {
57+
return null;
58+
}
59+
if ($scope instanceof ThinnedScope) {
60+
$v = $scope->getReservationDuration();
61+
return $v !== null ? (int) $v : null;
62+
}
63+
$v = $scope?->toProperty()?->preferences?->appointment?->reservationDuration?->get();
64+
return $v !== null ? (int) $v : null;
65+
}
66+
5467
/**
5568
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
5669
* @SuppressWarnings(PHPMD.NPathComplexity)
@@ -71,6 +84,8 @@ public static function mapOfficesWithScope(ProviderList $providerList, bool $sho
7184
continue;
7285
}
7386

87+
$rd = self::extractReservationDuration($providerScope);
88+
7489
$offices[] = new Office(
7590
id: isset($provider->id) ? (int) $provider->id : 0,
7691
name: isset($provider->displayName) ? $provider->displayName : (isset($provider->name) ? $provider->name : null),
@@ -105,7 +120,8 @@ public static function mapOfficesWithScope(ProviderList $providerList, bool $sho
105120
? ((string) $providerScope->infoForAllAppointments === '' ? null : (string) $providerScope->infoForAllAppointments)
106121
: null,
107122
appointmentsPerMail: isset($providerScope->appointmentsPerMail) ? ((string) $providerScope->appointmentsPerMail === '' ? null : (string) $providerScope->appointmentsPerMail) : null,
108-
whitelistedMails: isset($providerScope->whitelistedMails) ? ((string) $providerScope->whitelistedMails === '' ? null : (string) $providerScope->whitelistedMails) : null
123+
whitelistedMails: isset($providerScope->whitelistedMails) ? ((string) $providerScope->whitelistedMails === '' ? null : (string) $providerScope->whitelistedMails) : null,
124+
reservationDuration: $rd,
109125
) : null,
110126
maxSlotsPerAppointment: isset($providerScope) && !isset($providerScope['errors']) && isset($providerScope->slotsPerAppointment) ? ((string) $providerScope->slotsPerAppointment === '' ? null : (string) $providerScope->slotsPerAppointment) : null
111127
);
@@ -259,7 +275,8 @@ public static function scopeToThinnedScope(Scope $scope): ThinnedScope
259275
: (string) $scope->data['slotsPerAppointment'])
260276
: null,
261277
appointmentsPerMail: isset($scope->data['appointmentsPerMail']) ? ((string) $scope->data['appointmentsPerMail'] === '' ? null : (string) $scope->data['appointmentsPerMail']) : null,
262-
whitelistedMails: isset($scope->data['whitelistedMails']) ? ((string) $scope->data['whitelistedMails'] === '' ? null : (string) $scope->data['whitelistedMails']) : null
278+
whitelistedMails: isset($scope->data['whitelistedMails']) ? ((string) $scope->data['whitelistedMails'] === '' ? null : (string) $scope->data['whitelistedMails']) : null,
279+
reservationDuration: MapperService::extractReservationDuration($scope),
263280
);
264281
}
265282

zmscitizenapi/src/Zmscitizenapi/Services/Core/ZmsApiFacadeService.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public static function getOffices(bool $showUnpublished = false): OfficeList
9191
}
9292

9393
$matchingScope = $scopeMap[$provider->source . '_' . $provider->id] ?? null;
94+
$rd = MapperService::extractReservationDuration($matchingScope);
9495
$offices[] = new Office(
9596
id: (int) $provider->id,
9697
name: $provider->displayName ?? $provider->name,
@@ -120,7 +121,8 @@ public static function getOffices(bool $showUnpublished = false): OfficeList
120121
infoForAllAppointments: $matchingScope->getInfoForAllAppointments(),
121122
slotsPerAppointment: ((string) $matchingScope->getSlotsPerAppointment() === '' ? null : (string) $matchingScope->getSlotsPerAppointment()),
122123
appointmentsPerMail: ((string) $matchingScope->getAppointmentsPerMail() === '' ? null : (string) $matchingScope->getAppointmentsPerMail()),
123-
whitelistedMails: ((string) $matchingScope->getWhitelistedMails() === '' ? null : (string) $matchingScope->getWhitelistedMails())
124+
whitelistedMails: ((string) $matchingScope->getWhitelistedMails() === '' ? null : (string) $matchingScope->getWhitelistedMails()),
125+
reservationDuration: $rd,
124126
) : null,
125127
maxSlotsPerAppointment: $matchingScope ? ((string) $matchingScope->getSlotsPerAppointment() === '' ? null : (string) $matchingScope->getSlotsPerAppointment()) : null
126128
);
@@ -157,6 +159,7 @@ public static function getScopes(): ThinnedScopeList|array
157159
$key = $provider->source . '_' . $provider->id;
158160
if (isset($scopeMap[$key])) {
159161
$matchingScope = $scopeMap[$key];
162+
$rd = MapperService::extractReservationDuration($matchingScope);
160163
$scopesProjectionList[] = new ThinnedScope(
161164
id: (int) $matchingScope->id,
162165
provider: MapperService::providerToThinnedProvider($provider),
@@ -176,7 +179,8 @@ public static function getScopes(): ThinnedScopeList|array
176179
infoForAllAppointments: $matchingScope->getInfoForAllAppointments(),
177180
slotsPerAppointment: ((string) $matchingScope->getSlotsPerAppointment() === '' ? null : (string) $matchingScope->getSlotsPerAppointment()),
178181
appointmentsPerMail: ((string) $matchingScope->getAppointmentsPerMail() === '' ? null : (string) $matchingScope->getAppointmentsPerMail()),
179-
whitelistedMails: ((string) $matchingScope->getWhitelistedMails() === '' ? null : (string) $matchingScope->getWhitelistedMails())
182+
whitelistedMails: ((string) $matchingScope->getWhitelistedMails() === '' ? null : (string) $matchingScope->getWhitelistedMails()),
183+
reservationDuration: $rd,
180184
);
181185
}
182186
}
@@ -271,6 +275,7 @@ public static function getScopeByOfficeId(int $officeId): ThinnedScope|array
271275
$finalProvider = $providerKey && isset($providerMap[$providerKey])
272276
? $providerMap[$providerKey]
273277
: $scopeProvider;
278+
$rd = MapperService::extractReservationDuration($matchingScope);
274279
$result = [
275280
'id' => $matchingScope->id,
276281
'provider' => MapperService::providerToThinnedProvider($finalProvider) ?? null,
@@ -290,7 +295,8 @@ public static function getScopeByOfficeId(int $officeId): ThinnedScope|array
290295
'infoForAllAppointments' => $matchingScope->getInfoForAllAppointments() ?? null,
291296
'slotsPerAppointment' => ((string) $matchingScope->getSlotsPerAppointment() === '' ? null : (string) $matchingScope->getSlotsPerAppointment()) ?? null,
292297
'appointmentsPerMail' => ((string) $matchingScope->getAppointmentsPerMail() === '' ? null : (string) $matchingScope->getAppointmentsPerMail()) ?? null,
293-
'whitelistedMails' => ((string) $matchingScope->getWhitelistedMails() === '' ? null : (string) $matchingScope->getWhitelistedMails()) ?? null
298+
'whitelistedMails' => ((string) $matchingScope->getWhitelistedMails() === '' ? null : (string) $matchingScope->getWhitelistedMails()) ?? null,
299+
'reservationDuration' => $rd,
294300
];
295301
return new ThinnedScope(
296302
id: (int) $result['id'],
@@ -311,7 +317,8 @@ public static function getScopeByOfficeId(int $officeId): ThinnedScope|array
311317
infoForAllAppointments: $result['infoForAllAppointments'],
312318
slotsPerAppointment: $result['slotsPerAppointment'],
313319
appointmentsPerMail: $result['appointmentsPerMail'],
314-
whitelistedMails: $result['whitelistedMails']
320+
whitelistedMails: $result['whitelistedMails'],
321+
reservationDuration: $result['reservationDuration']
315322
);
316323
}
317324

@@ -423,6 +430,7 @@ public static function getScopeById(?int $scopeId): ThinnedScope|array
423430
$matchingProv = ($providerKey && isset($providerMap[$providerKey]))
424431
? $providerMap[$providerKey]
425432
: $scopeProvider;
433+
$rd = MapperService::extractReservationDuration($matchingScope);
426434
return new ThinnedScope(
427435
id: (int) $matchingScope->id,
428436
provider: MapperService::providerToThinnedProvider($matchingProv),
@@ -442,7 +450,8 @@ public static function getScopeById(?int $scopeId): ThinnedScope|array
442450
infoForAllAppointments: $matchingScope->getInfoForAllAppointments() ?? null,
443451
slotsPerAppointment: ((string) $matchingScope->getSlotsPerAppointment() === '' ? null : (string) $matchingScope->getSlotsPerAppointment()) ?? null,
444452
appointmentsPerMail: ((string) $matchingScope->getAppointmentsPerMail() === '' ? null : (string) $matchingScope->getAppointmentsPerMail()) ?? null,
445-
whitelistedMails: ((string) $matchingScope->getWhitelistedMails() === '' ? null : (string) $matchingScope->getWhitelistedMails()) ?? null
453+
whitelistedMails: ((string) $matchingScope->getWhitelistedMails() === '' ? null : (string) $matchingScope->getWhitelistedMails()) ?? null,
454+
reservationDuration: $rd,
446455
);
447456
}
448457

@@ -705,6 +714,7 @@ public static function getThinnedProcessById(?int $processId, ?string $authKey):
705714
$providerKey = $scopeProvider ? ($scopeProvider->getSource() . '_' . $scopeProvider->id) : null;
706715
$matchingProvider = $providerKey && isset($providerMap[$providerKey]) ? $providerMap[$providerKey] : $scopeProvider;
707716
$thinnedProvider = MapperService::providerToThinnedProvider($matchingProvider);
717+
$rd = MapperService::extractReservationDuration($process->scope);
708718
$thinnedScope = new ThinnedScope(
709719
id: (int) $process->scope->id,
710720
provider: $thinnedProvider,
@@ -724,7 +734,8 @@ public static function getThinnedProcessById(?int $processId, ?string $authKey):
724734
infoForAllAppointments: $process->scope->getInfoForAllAppointments() ?? null,
725735
slotsPerAppointment: ((string) $process->scope->getSlotsPerAppointment() === '' ? null : (string) $process->scope->getSlotsPerAppointment()) ?? null,
726736
appointmentsPerMail: ((string) $process->scope->getAppointmentsPerMail() === '' ? null : (string) $process->scope->getAppointmentsPerMail()) ?? null,
727-
whitelistedMails: ((string) $process->scope->getWhitelistedMails() === '' ? null : (string) $process->scope->getWhitelistedMails()) ?? null
737+
whitelistedMails: ((string) $process->scope->getWhitelistedMails() === '' ? null : (string) $process->scope->getWhitelistedMails()) ?? null,
738+
reservationDuration: $rd,
728739
);
729740
}
730741

zmscitizenapi/tests/Zmscitizenapi/Controllers/Appointment/AppointmentByIdControllerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ public function testRendering()
103103
"infoForAllAppointments" => null,
104104
"slotsPerAppointment" => null,
105105
"appointmentsPerMail" => 1,
106-
"whitelistedMails" => null
106+
"whitelistedMails" => null,
107+
"reservationDuration" => 15
107108
],
108109
"subRequestCounts" => [],
109110
"serviceId" => 1063424,

zmscitizenapi/tests/Zmscitizenapi/Controllers/Appointment/AppointmentCancelControllerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ public function testRendering()
107107
'infoForAllAppointments' => null,
108108
'slotsPerAppointment' => null,
109109
"appointmentsPerMail" => null,
110-
"whitelistedMails" => null
110+
"whitelistedMails" => null,
111+
"reservationDuration" => null
111112
],
112113
'subRequestCounts' => [],
113114
'serviceId' => 10242339,

zmscitizenapi/tests/Zmscitizenapi/Controllers/Appointment/AppointmentConfirmControllerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ public function testRendering()
104104
'infoForAllAppointments' => null,
105105
'slotsPerAppointment' => null,
106106
"appointmentsPerMail" => null,
107-
"whitelistedMails" => null
107+
"whitelistedMails" => null,
108+
"reservationDuration" => null
108109
],
109110
'subRequestCounts' => [],
110111
'serviceId' => 10242339,

zmscitizenapi/tests/Zmscitizenapi/Controllers/Appointment/AppointmentPreconfirmControllerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ public function testRendering()
102102
'infoForAllAppointments' => null,
103103
'slotsPerAppointment' => null,
104104
"appointmentsPerMail" => null,
105-
"whitelistedMails" => null
105+
"whitelistedMails" => null,
106+
"reservationDuration" => null
106107
],
107108
'subRequestCounts' => [],
108109
'serviceId' => 10242339,

zmscitizenapi/tests/Zmscitizenapi/Controllers/Appointment/AppointmentReserveControllerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ public function testRendering()
106106
"infoForAllAppointments" => null,
107107
"slotsPerAppointment" => null,
108108
"appointmentsPerMail" => null,
109-
"whitelistedMails" => null
109+
"whitelistedMails" => null,
110+
"reservationDuration" => null
110111
],
111112
"subRequestCounts" => [],
112113
"serviceId" => 0,

0 commit comments

Comments
 (0)