Skip to content

Commit cc6cebe

Browse files
ArtificialOwlbackportbot[bot]
authored andcommitted
force local request on local broadcast
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
1 parent 62b92c6 commit cc6cebe

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

lib/Service/ConfigService.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ public function getTrustedDomains(): array {
544544
* - use 'overwrite.cli.url'
545545
* - can use the first entry from trusted_domains is LOCAL_CLOUD_ID = 'use-trusted-domain'
546546
* - used mainly to assign instance and source to a request
547+
* - important only in remote environment; can be totally random in a jailed environment
547548
*
548549
* @return string
549550
*/

lib/Service/GSUpstreamService.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ public function newEvent(GSEvent $event): string {
136136

137137
try {
138138
$gs = $this->globalScaleService->getGlobalScaleEvent($event);
139-
140139
if ($this->isLocalEvent($event)) {
141140
$gs->verify($event, true);
142141
if (!$event->isAsync()) {
@@ -196,16 +195,21 @@ public function broadcastWrapper(GSWrapper $wrapper, string $protocol): void {
196195
public function broadcastEvent(GSEvent $event, string $instance, string $protocol = ''): void {
197196
$this->signEvent($event);
198197

199-
$path = $this->urlGenerator->linkToRoute('circles.GlobalScale.broadcast');
200-
$request = new NC19Request($path, Request::TYPE_POST);
201-
$this->configService->configureRequest($request);
202-
$protocols = ['https', 'http'];
203-
if ($protocol !== '') {
204-
$protocols = [$protocol];
198+
if ($this->configService->isLocalInstance($instance)) {
199+
$request = new NC19Request('', Request::TYPE_POST);
200+
$this->configService->configureRequest($request, 'circles.GlobalScale.broadcast');
201+
} else {
202+
$path = $this->urlGenerator->linkToRoute('circles.GlobalScale.broadcast');
203+
$request = new NC19Request($path, Request::TYPE_POST);
204+
$this->configService->configureRequest($request);
205+
$protocols = ['https', 'http'];
206+
if ($protocol !== '') {
207+
$protocols = [$protocol];
208+
}
209+
$request->setInstance($instance);
210+
$request->setProtocols($protocols);
205211
}
206212

207-
$request->setHost($instance);
208-
$request->setProtocols($protocols);
209213
$request->setDataSerialize($event);
210214

211215
$data = $this->retrieveJson($request);

0 commit comments

Comments
 (0)