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.
This commit is contained in:
Feross Aboukhadijeh
2016-05-19 20:03:02 -07:00
parent 74ada99f2b
commit 22cdcdb468
3 changed files with 31 additions and 0 deletions

View File

@@ -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'),

27
main/announcement.js Normal file
View File

@@ -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()
})
})
}

View File

@@ -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()