Skip to content

Commit 87fcc8c

Browse files
authored
Merge pull request #18694 from nextcloud/backport/18442/stable17
[stable17] Restore old behavior allowing to set custom appstore
2 parents cbde341 + 8bd5231 commit 87fcc8c

5 files changed

Lines changed: 23 additions & 10 deletions

File tree

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

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

6868
$this->fileName = 'apps.json';
69-
$this->setEndpoint();
7069
$this->compareVersion = $compareVersion;
7170
$this->ignoreMaxVersion = true;
7271
}
@@ -141,10 +140,6 @@ protected function fetch($ETag, $content) {
141140
return $response;
142141
}
143142

144-
private function setEndpoint() {
145-
$this->endpointUrl = 'https://apps.nextcloud.com/api/v1/apps.json';
146-
}
147-
148143
/**
149144
* @param string $version
150145
* @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
@@ -54,8 +54,6 @@ abstract class Fetcher {
5454
/** @var string */
5555
protected $fileName;
5656
/** @var string */
57-
protected $endpointUrl;
58-
/** @var string */
5957
protected $version;
6058
/** @var string */
6159
protected $channel;
@@ -105,7 +103,7 @@ protected function fetch($ETag, $content) {
105103
}
106104

107105
$client = $this->clientService->newClient();
108-
$response = $client->get($this->endpointUrl, $options);
106+
$response = $client->get($this->getEndpoint(), $options);
109107

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

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)