Skip to content

Commit 3566817

Browse files
committed
fix(federated-teams): ignore duplicate instance and generate logs
Signed-off-by: Maxence Lange <[email protected]>
1 parent 4b981de commit 3566817

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/Service/FederatedEventService.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,19 +395,27 @@ public function initBroadcast(FederatedEvent $event): bool {
395395
$wrapper->setCreation(time());
396396
$wrapper->setSeverity($event->getSeverity());
397397

398+
$avoidDuplicate = [];
398399
if ($event->isAsync()) {
399400
$wrapper->setInstance($this->configService->getLoopbackInstance());
400401
$this->eventWrapperRequest->save($wrapper);
402+
$avoidDuplicate[] = $this->configService->getLoopbackInstance();
401403
}
402404

403405
foreach ($instances as $instance) {
404406
if ($event->getCircle()->isConfig(Circle::CFG_LOCAL)) {
405407
break;
406408
}
407409

410+
if (in_array($instance->getInstance(), $avoidDuplicate, true)) {
411+
Server::get(\Psr\Log\LoggerInterface::class)->warning('duplicate instance, please verify the setup of Federated Teams', ['duplicate' => $avoidDuplicate, 'instance' => $instance->getInstance(), 'interface' => $instance->getInterface()]);
412+
continue;
413+
}
414+
408415
$wrapper->setInstance($instance->getInstance());
409416
$wrapper->setInterface($instance->getInterface());
410417
$this->eventWrapperRequest->save($wrapper);
418+
$avoidDuplicate[] = $wrapper->getInstance();
411419
}
412420

413421
$request = new NCRequest('', Request::TYPE_POST);

0 commit comments

Comments
 (0)