Skip to content

Commit e5d7782

Browse files
authored
Merge pull request #18442 from nextcloud/bugfix/noid/broken_appstoreurl_config
Restore old behavior allowing to set custom appstore
2 parents bb93be2 + f0bef88 commit e5d7782

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

lib/private/App/AppStore/Fetcher/AppFetcher.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ public function __construct(Factory $appDataFactory,
6868
);
6969

7070
$this->fileName = 'apps.json';
71-
$this->setEndpoint();
7271
$this->compareVersion = $compareVersion;
7372
$this->ignoreMaxVersion = true;
7473
}
@@ -143,10 +142,6 @@ protected function fetch($ETag, $content) {
143142
return $response;
144143
}
145144

146-
private function setEndpoint() {
147-
$this->endpointUrl = 'https://apps.nextcloud.com/api/v1/apps.json';
148-
}
149-
150145
/**
151146
* @param string $version
152147
* @param string $fileName

lib/private/App/AppStore/Fetcher/CategoryFetcher.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,5 @@ public function __construct(Factory $appDataFactory,
5353
$logger
5454
);
5555
$this->fileName = 'categories.json';
56-
$this->endpointUrl = 'https://apps.nextcloud.com/api/v1/categories.json';
5756
}
5857
}

lib/private/App/AppStore/Fetcher/Fetcher.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ abstract class Fetcher {
5555
/** @var string */
5656
protected $fileName;
5757
/** @var string */
58-
protected $endpointUrl;
59-
/** @var string */
6058
protected $version;
6159
/** @var string */
6260
protected $channel;
@@ -106,7 +104,7 @@ protected function fetch($ETag, $content) {
106104
}
107105

108106
$client = $this->clientService->newClient();
109-
$response = $client->get($this->endpointUrl, $options);
107+
$response = $client->get($this->getEndpoint(), $options);
110108

111109
$responseJson = [];
112110
if ($response->getStatusCode() === Http::STATUS_NOT_MODIFIED) {
@@ -219,4 +217,8 @@ protected function getChannel() {
219217
public function setChannel(string $channel) {
220218
$this->channel = $channel;
221219
}
220+
221+
protected function getEndpoint(): string {
222+
return $this->config->getSystemValue('appstoreurl', 'https://apps.nextcloud.com/api/v1') . '/' . $this->fileName;
223+
}
222224
}

tests/lib/App/AppStore/Fetcher/AppFetcherTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ public function testGetWithFilter() {
9292
return true;
9393
} else if ($key === 'version') {
9494
return '11.0.0.2';
95+
} else if ($key === 'appstoreurl' && $default === 'https://apps.nextcloud.com/api/v1') {
96+
return 'https://custom.appsstore.endpoint/api/v1';
9597
} else {
9698
return $default;
9799
}
@@ -122,7 +124,7 @@ public function testGetWithFilter() {
122124
$response = $this->createMock(IResponse::class);
123125
$client
124126
->method('get')
125-
->with('https://apps.nextcloud.com/api/v1/apps.json')
127+
->with('https://custom.appsstore.endpoint/api/v1/apps.json')
126128
->willReturn($response);
127129
$response
128130
->expects($this->once())

tests/lib/App/AppStore/Fetcher/FetcherBase.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ public function testGetWithNotExistingFileAndUpToDateTimestampAndVersion() {
137137
$this->config
138138
->expects($this->at(3))
139139
->method('getSystemValue')
140+
->with('appstoreurl', 'https://apps.nextcloud.com/api/v1')
141+
->willReturn('https://apps.nextcloud.com/api/v1');
142+
$this->config
143+
->expects($this->at(4))
144+
->method('getSystemValue')
140145
->with(
141146
$this->equalTo('version'),
142147
$this->anything()
@@ -298,6 +303,11 @@ public function testGetWithAlreadyExistingFileAndNoVersion() {
298303
$this->config
299304
->expects($this->at(3))
300305
->method('getSystemValue')
306+
->with('appstoreurl', 'https://apps.nextcloud.com/api/v1')
307+
->willReturn('https://apps.nextcloud.com/api/v1');
308+
$this->config
309+
->expects($this->at(4))
310+
->method('getSystemValue')
301311
->with(
302312
$this->equalTo('version'),
303313
$this->anything()
@@ -382,6 +392,11 @@ public function testGetWithAlreadyExistingFileAndOutdatedVersion() {
382392
$this->config
383393
->expects($this->at(3))
384394
->method('getSystemValue')
395+
->with('appstoreurl', 'https://apps.nextcloud.com/api/v1')
396+
->willReturn('https://apps.nextcloud.com/api/v1');
397+
$this->config
398+
->expects($this->at(4))
399+
->method('getSystemValue')
385400
->with(
386401
$this->equalTo('version'),
387402
$this->anything()

0 commit comments

Comments
 (0)