Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/updatenotification/controller/admincontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public function displayPanel() {
'channels' => $channels,
'newVersionString' => ($updateState === []) ? '' : $updateState['updateVersion'],
'updaterRequirementsFulfilled' => $this->isCompatibleWithUpdater(),
'downloadLink' => (empty($updateState['downloadLink'])) ? '' : $updateState['downloadLink'],
];

return new TemplateResponse($this->appName, 'admin', $params, '');
Expand Down
25 changes: 0 additions & 25 deletions apps/updatenotification/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,7 @@
/**
* Creates a new authentication token and loads the updater URL
*/
var loginToken = '';
$(document).ready(function(){
$('#oca_updatenotification_button').click(function() {
// Load the new token
$.ajax({
url: OC.generateUrl('/apps/updatenotification/credentials')
}).success(function(data) {
loginToken = data;
$.ajax({
url: OC.webroot+'/updater/',
headers: {
'X-Updater-Auth': loginToken
},
method: 'POST',
success: function(data){
if(data !== 'false') {
var body = $('body');
$('head').remove();
body.html(data);
body.removeAttr('id');
body.attr('id', 'body-settings');
}
}
});
});
});
$('#release-channel').change(function() {
var newChannel = $('#release-channel').find(":selected").val();
$.post(
Expand Down
3 changes: 3 additions & 0 deletions apps/updatenotification/lib/updatechecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public function getUpdateState() {
if(substr($data['web'], 0, 8) === 'https://') {
$result['updateLink'] = $data['web'];
}
if(substr($data['url'], 0, 8) === 'https://') {
$result['downloadLink'] = $data['url'];
}

return $result;
}
Expand Down
6 changes: 2 additions & 4 deletions apps/updatenotification/templates/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@

<?php if($isNewVersionAvailable === true): ?>
<strong><?php p($l->t('A new version is available: %s', [$newVersionString])); ?></strong>
<?php if($updaterRequirementsFulfilled === true): ?>
<input type="button" id="oca_updatenotification_button" value="<?php p($l->t('Open updater')) ?>">
<?php else: ?>
<br/><?php p($l->t('At the moment only manual updates are supported on your environment. This is very likely the case because functions such as shell_exec are not available.')); ?>
<?php if ($_['downloadLink']): ?>
<a href="<?php p($_['downloadLink']); ?>" class="button"><?php p($l->t('Download now')) ?></a>
<?php endif; ?>
<?php else: ?>
<strong><?php print_unescaped($l->t('Your version is up to date.')); ?></strong>
Expand Down
15 changes: 9 additions & 6 deletions apps/updatenotification/tests/UpdateCheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ public function testGetUpdateStateWithUpdateAndInvalidLink() {
->method('check')
->willReturn([
'version' => 123,
'versionstring' => 'ownCloud 123',
'versionstring' => 'Nextcloud 123',
'web'=> 'javascript:alert(1)',
'url'=> 'javascript:alert(2)',
]);

$expected = [
'updateAvailable' => true,
'updateVersion' => 'ownCloud 123',
'updateVersion' => 'Nextcloud 123',
];
$this->assertSame($expected, $this->updateChecker->getUpdateState());
}
Expand All @@ -63,14 +64,16 @@ public function testGetUpdateStateWithUpdateAndValidLink() {
->method('check')
->willReturn([
'version' => 123,
'versionstring' => 'ownCloud 123',
'web'=> 'https://owncloud.org/myUrl',
'versionstring' => 'Nextcloud 123',
'web'=> 'https://docs.nextcloud.com/myUrl',
'url'=> 'https://downloads.nextcloud.org/server',
]);

$expected = [
'updateAvailable' => true,
'updateVersion' => 'ownCloud 123',
'updateLink' => 'https://owncloud.org/myUrl',
'updateVersion' => 'Nextcloud 123',
'updateLink' => 'https://docs.nextcloud.com/myUrl',
'downloadLink' => 'https://downloads.nextcloud.org/server',
];
$this->assertSame($expected, $this->updateChecker->getUpdateState());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public function testDisplayPanelWithUpdate() {
'channels' => $channels,
'newVersionString' => '8.1.2',
'updaterRequirementsFulfilled' => true,
'downloadLink' => '',
];

$expected = new TemplateResponse('updatenotification', 'admin', $params, '');
Expand Down Expand Up @@ -160,7 +161,10 @@ public function testDisplayPanelWithUpdateAndIncompatibleUpdaterApp() {
$this->updateChecker
->expects($this->once())
->method('getUpdateState')
->willReturn(['updateVersion' => '8.1.2']);
->willReturn([
'updateVersion' => '8.1.2',
'downloadLink' => 'https://downloads.nextcloud.org/server',
]);
$this->adminController
->expects($this->once())
->method('isCompatibleWithUpdater')
Expand All @@ -173,6 +177,7 @@ public function testDisplayPanelWithUpdateAndIncompatibleUpdaterApp() {
'channels' => $channels,
'newVersionString' => '8.1.2',
'updaterRequirementsFulfilled' => false,
'downloadLink' => 'https://downloads.nextcloud.org/server',
];

$expected = new TemplateResponse('updatenotification', 'admin', $params, '');
Expand Down Expand Up @@ -219,6 +224,7 @@ public function testDisplayPanelWithoutUpdate() {
'channels' => $channels,
'newVersionString' => '',
'updaterRequirementsFulfilled' => true,
'downloadLink' => '',
];

$expected = new TemplateResponse('updatenotification', 'admin', $params, '');
Expand Down
2 changes: 1 addition & 1 deletion config/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@
/**
* URL that Nextcloud should use to look for updates
*/
'updater.server.url' => 'https://updates.nextcloud.org/server/',
'updater.server.url' => 'https://updates.nextcloud.com/update-server/',

/**
* Release channel to use for updates
Expand Down
2 changes: 1 addition & 1 deletion lib/private/updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function check() {
return json_decode($this->config->getAppValue('core', 'lastupdateResult'), true);
}

$updaterUrl = $this->config->getSystemValue('updater.server.url', 'https://updates.nextcloud.org/server/');
$updaterUrl = $this->config->getSystemValue('updater.server.url', 'https://updates.nextcloud.com/update-server/');

$this->config->setAppValue('core', 'lastupdatedat', time());

Expand Down
24 changes: 12 additions & 12 deletions tests/lib/updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ public function testCheckWithoutUpdateUrl() {
$this->config
->expects($this->at(1))
->method('getSystemValue')
->with('updater.server.url', 'https://updates.nextcloud.org/server/')
->willReturn('https://updates.nextcloud.org/server/');
->with('updater.server.url', 'https://updates.nextcloud.com/update-server/')
->willReturn('https://updates.nextcloud.com/update-server/');
$this->config
->expects($this->at(2))
->method('setAppValue')
Expand Down Expand Up @@ -253,7 +253,7 @@ public function testCheckWithoutUpdateUrl() {
$this->httpHelper
->expects($this->once())
->method('getUrlContent')
->with($this->buildUpdateUrl('https://updates.nextcloud.org/server/'))
->with($this->buildUpdateUrl('https://updates.nextcloud.com/update-server/'))
->will($this->returnValue($updateXml));

$this->assertSame($expectedResult, $this->updater->check());
Expand All @@ -268,8 +268,8 @@ public function testCheckWithInvalidXml() {
$this->config
->expects($this->at(1))
->method('getSystemValue')
->with('updater.server.url', 'https://updates.nextcloud.org/server/')
->willReturn('https://updates.nextcloud.org/server/');
->with('updater.server.url', 'https://updates.nextcloud.com/update-server/')
->willReturn('https://updates.nextcloud.com/update-server/');
$this->config
->expects($this->at(2))
->method('setAppValue')
Expand All @@ -293,7 +293,7 @@ public function testCheckWithInvalidXml() {
$this->httpHelper
->expects($this->once())
->method('getUrlContent')
->with($this->buildUpdateUrl('https://updates.nextcloud.org/server/'))
->with($this->buildUpdateUrl('https://updates.nextcloud.com/update-server/'))
->will($this->returnValue($updateXml));

$this->assertSame([], $this->updater->check());
Expand All @@ -315,8 +315,8 @@ public function testCheckWithEmptyValidXmlResponse() {
$this->config
->expects($this->at(1))
->method('getSystemValue')
->with('updater.server.url', 'https://updates.nextcloud.org/server/')
->willReturn('https://updates.nextcloud.org/server/');
->with('updater.server.url', 'https://updates.nextcloud.com/update-server/')
->willReturn('https://updates.nextcloud.com/update-server/');
$this->config
->expects($this->at(2))
->method('setAppValue')
Expand All @@ -342,7 +342,7 @@ public function testCheckWithEmptyValidXmlResponse() {
$this->httpHelper
->expects($this->once())
->method('getUrlContent')
->with($this->buildUpdateUrl('https://updates.nextcloud.org/server/'))
->with($this->buildUpdateUrl('https://updates.nextcloud.com/update-server/'))
->will($this->returnValue($updateXml));

$this->assertSame($expectedResult, $this->updater->check());
Expand All @@ -359,8 +359,8 @@ public function testCheckWithEmptyInvalidXmlResponse() {
$this->config
->expects($this->at(1))
->method('getSystemValue')
->with('updater.server.url', 'https://updates.nextcloud.org/server/')
->willReturn('https://updates.nextcloud.org/server/');
->with('updater.server.url', 'https://updates.nextcloud.com/update-server/')
->willReturn('https://updates.nextcloud.com/update-server/');
$this->config
->expects($this->at(2))
->method('setAppValue')
Expand All @@ -384,7 +384,7 @@ public function testCheckWithEmptyInvalidXmlResponse() {
$this->httpHelper
->expects($this->once())
->method('getUrlContent')
->with($this->buildUpdateUrl('https://updates.nextcloud.org/server/'))
->with($this->buildUpdateUrl('https://updates.nextcloud.com/update-server/'))
->will($this->returnValue($updateXml));

$this->assertSame($expectedResult, $this->updater->check());
Expand Down