diff --git a/apps/updatenotification/js/admin.js b/apps/updatenotification/js/admin.js index 3ca45a191d..e60e77ab89 100644 --- a/apps/updatenotification/js/admin.js +++ b/apps/updatenotification/js/admin.js @@ -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(); diff --git a/apps/updatenotification/lib/Controller/AdminController.php b/apps/updatenotification/lib/Controller/AdminController.php index 9f10f1b32f..16ae8144b1 100644 --- a/apps/updatenotification/lib/Controller/AdminController.php +++ b/apps/updatenotification/lib/Controller/AdminController.php @@ -112,6 +112,7 @@ class AdminController extends Controller implements ISettings { 'currentChannel' => $currentChannel, 'channels' => $channels, 'newVersionString' => ($updateState === []) ? '' : $updateState['updateVersion'], + 'downloadLink' => (empty($updateState['downloadLink'])) ? '' : $updateState['downloadLink'], 'notify_groups' => implode('|', $notifyGroups), ]; diff --git a/apps/updatenotification/lib/UpdateChecker.php b/apps/updatenotification/lib/UpdateChecker.php index dd51831007..5f759b7c84 100644 --- a/apps/updatenotification/lib/UpdateChecker.php +++ b/apps/updatenotification/lib/UpdateChecker.php @@ -49,6 +49,9 @@ class UpdateChecker { if(substr($data['web'], 0, 8) === 'https://') { $result['updateLink'] = $data['web']; } + if(substr($data['url'], 0, 8) === 'https://') { + $result['downloadLink'] = $data['url']; + } return $result; } diff --git a/apps/updatenotification/templates/admin.php b/apps/updatenotification/templates/admin.php index 68ef1d423b..0dd8aec4a0 100644 --- a/apps/updatenotification/templates/admin.php +++ b/apps/updatenotification/templates/admin.php @@ -16,7 +16,9 @@
t('A new version is available: %s', [$newVersionString])); ?> - + + t('Download now')) ?> + t('Your version is up to date.')); ?> diff --git a/apps/updatenotification/tests/Controller/AdminControllerTest.php b/apps/updatenotification/tests/Controller/AdminControllerTest.php index cf99679e68..92d2ee6dbe 100644 --- a/apps/updatenotification/tests/Controller/AdminControllerTest.php +++ b/apps/updatenotification/tests/Controller/AdminControllerTest.php @@ -110,7 +110,10 @@ class AdminControllerTest extends TestCase { $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, @@ -119,6 +122,7 @@ class AdminControllerTest extends TestCase { 'channels' => $channels, 'newVersionString' => '8.1.2', 'notify_groups' => 'admin', + 'downloadLink' => 'https://downloads.nextcloud.org/server', ]; $expected = new TemplateResponse('updatenotification', 'admin', $params, ''); @@ -163,6 +167,7 @@ class AdminControllerTest extends TestCase { 'channels' => $channels, 'newVersionString' => '', 'notify_groups' => 'admin', + 'downloadLink' => '', ]; $expected = new TemplateResponse('updatenotification', 'admin', $params, ''); diff --git a/apps/updatenotification/tests/UpdateCheckerTest.php b/apps/updatenotification/tests/UpdateCheckerTest.php index c2c9ba1438..38e64b6b5e 100644 --- a/apps/updatenotification/tests/UpdateCheckerTest.php +++ b/apps/updatenotification/tests/UpdateCheckerTest.php @@ -47,13 +47,14 @@ class UpdateCheckerTest extends TestCase { ->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()); } @@ -64,14 +65,16 @@ class UpdateCheckerTest extends TestCase { ->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()); } diff --git a/config/config.sample.php b/config/config.sample.php index d761ae92c2..d706b4321b 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -519,7 +519,7 @@ $CONFIG = array( /** * 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? diff --git a/lib/private/Updater/VersionCheck.php b/lib/private/Updater/VersionCheck.php index a4416986f0..021abc95a5 100644 --- a/lib/private/Updater/VersionCheck.php +++ b/lib/private/Updater/VersionCheck.php @@ -59,7 +59,7 @@ class VersionCheck { 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()); diff --git a/tests/lib/Updater/VersionCheckTest.php b/tests/lib/Updater/VersionCheckTest.php index 99245b5801..7517ab321a 100644 --- a/tests/lib/Updater/VersionCheckTest.php +++ b/tests/lib/Updater/VersionCheckTest.php @@ -91,8 +91,8 @@ class VersionCheckTest extends \Test\TestCase { $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') @@ -122,7 +122,7 @@ class VersionCheckTest extends \Test\TestCase { $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()); @@ -137,8 +137,8 @@ class VersionCheckTest extends \Test\TestCase { $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') @@ -162,7 +162,7 @@ class VersionCheckTest extends \Test\TestCase { $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()); @@ -184,8 +184,8 @@ class VersionCheckTest extends \Test\TestCase { $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') @@ -211,7 +211,7 @@ class VersionCheckTest extends \Test\TestCase { $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()); @@ -228,8 +228,8 @@ class VersionCheckTest extends \Test\TestCase { $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') @@ -253,7 +253,7 @@ class VersionCheckTest extends \Test\TestCase { $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());