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
26 changes: 0 additions & 26 deletions apps/updatenotification/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public function displayPanel() {
'currentChannel' => $currentChannel,
'channels' => $channels,
'newVersionString' => ($updateState === []) ? '' : $updateState['updateVersion'],
'downloadLink' => (empty($updateState['downloadLink'])) ? '' : $updateState['downloadLink'],

'notify_groups' => implode('|', $notifyGroups),
];
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 @@ -49,6 +49,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
4 changes: 3 additions & 1 deletion apps/updatenotification/templates/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
<form id="oca_updatenotification_section" class="followupsection">
<?php if($isNewVersionAvailable === true): ?>
<strong><?php p($l->t('A new version is available: %s', [$newVersionString])); ?></strong>
<input type="button" id="oca_updatenotification_button" value="<?php p($l->t('Open updater')) ?>">
<?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>
<span class="icon-info svg" title="<?php p($l->t('Checked on %s', [$lastCheckedDate])) ?>"></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ public function testDisplayPanelWithUpdate() {
$this->updateChecker
->expects($this->once())
->method('getUpdateState')
->willReturn(['updateVersion' => '8.1.2']);
->willReturn([
'updateVersion' => '8.1.2',
'downloadLink' => 'https://downloads.nextcloud.org/server',
]);

$params = [
'isNewVersionAvailable' => true,
Expand All @@ -120,6 +123,7 @@ public function testDisplayPanelWithUpdate() {
'channels' => $channels,
'newVersionString' => '8.1.2',
'notify_groups' => 'admin',
'downloadLink' => 'https://downloads.nextcloud.org/server',
];

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

$expected = new TemplateResponse('updatenotification', 'admin', $params, '');
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 @@ -47,13 +47,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 @@ -64,14 +65,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
2 changes: 1 addition & 1 deletion config/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,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/',

/**
* Is Nextcloud connected to the Internet or running in a closed network?
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Updater/VersionCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function check() {
return json_decode($this->config->getAppValue('core', 'lastupdateResult'), true);
}

$updaterUrl = $this->config->getSystemValue('updater.server.url', 'https://updates.nextcloud.com/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/VersionCheckTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ public function testCheckWithoutUpdateUrl() {
$this->config
->expects($this->at(1))
->method('getSystemValue')
->with('updater.server.url', 'https://updates.nextcloud.com/server/')
->willReturn('https://updates.nextcloud.com/server/');
->with('updater.server.url', 'https://updates.nextcloud.com/update-server/')
->willReturnArgument(1);
$this->config
->expects($this->at(2))
->method('setAppValue')
Expand Down Expand Up @@ -124,7 +124,7 @@ public function testCheckWithoutUpdateUrl() {
$this->updater
->expects($this->once())
->method('getUrlContent')
->with($this->buildUpdateUrl('https://updates.nextcloud.com/server/'))
->with($this->buildUpdateUrl('https://updates.nextcloud.com/update-server/'))
->will($this->returnValue($updateXml));

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

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

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

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