From 22cdcdb468d089a0c8b07e85fea34fca72d3cf18 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 19 May 2016 20:03:02 -0700 Subject: [PATCH] Add announcement feature If there's a message returned by the given remote URL, then it will show up for the user. Useful in situations where the auto-updater is not working, or if there's a security issue. --- config.js | 2 ++ main/announcement.js | 27 +++++++++++++++++++++++++++ main/index.js | 2 ++ 3 files changed, 31 insertions(+) create mode 100644 main/announcement.js diff --git a/config.js b/config.js index db96cfab..95da64fc 100644 --- a/config.js +++ b/config.js @@ -9,6 +9,8 @@ var APP_VERSION = require('./package.json').version var PORTABLE_PATH = path.join(path.dirname(process.execPath), 'Portable Settings') module.exports = { + ANNOUNCEMENT_URL: 'https://webtorrent.io/desktop/announcement', + APP_COPYRIGHT: 'Copyright © 2014-2016 ' + APP_TEAM, APP_FILE_ICON: path.join(__dirname, 'static', 'WebTorrentFile'), APP_ICON: path.join(__dirname, 'static', 'WebTorrent'), diff --git a/main/announcement.js b/main/announcement.js new file mode 100644 index 00000000..a68f005f --- /dev/null +++ b/main/announcement.js @@ -0,0 +1,27 @@ +module.exports = { + init +} + +var electron = require('electron') +var get = require('simple-get') + +var config = require('../config') +var log = require('./log') + +var ANNOUNCEMENT_URL = config.ANNOUNCEMENT_URL + + '?version=' + config.APP_VERSION + + '&platform=' + process.platform + +function init () { + get.concat(ANNOUNCEMENT_URL, function (err, res, data) { + if (err) return log('failed to retrieve remote message') + if (res.statusCode !== 200) return log('no remote message') + + electron.dialog.showMessageBox({ + type: 'info', + buttons: ['OK'], + title: 'WebTorrent Desktop Announcement', + message: data.toString() + }) + }) +} diff --git a/main/index.js b/main/index.js index 6b6f63bf..83a3f5dc 100644 --- a/main/index.js +++ b/main/index.js @@ -5,6 +5,7 @@ var electron = require('electron') var app = electron.app var ipcMain = electron.ipcMain +var announcement = require('./announcement') var config = require('../config') var crashReporter = require('../crash-reporter') var handlers = require('./handlers') @@ -91,6 +92,7 @@ function init () { } function delayedInit () { + announcement.init() tray.init() handlers.install() updater.init()