Browse Source

add and fix checks for daemon version and input data for short URI related functions

readme-update
Simon Grim 9 years ago
parent
commit
ee7f84d2b6
  1. 14
      js/interface_common.js
  2. 4
      js/twister_actions.js
  3. 6
      js/twister_io.js

14
js/interface_common.js

@ -808,7 +808,17 @@ function openRequestShortURIForm() { @@ -808,7 +808,17 @@ function openRequestShortURIForm() {
//txtTitle: polyglot.t(''), add some title (not 'error', please) or just KISS
txtMessage: 'You can\'t short links because you are not logged in.'
});
return;
}
if (parseInt(twisterVersion) < 93500) {
alertPopup({
//txtTitle: polyglot.t(''), add some title (not 'error', please) or just KISS
txtMessage: 'You can\'t short links because twister daemon is obsolete!\n'
+ 'Version 0.9.35 or higher is required. Please keep your twister up to date.'
});
return;
}
var uri = prompt('enter a link, watch yourself carefully'); // FIXME
newShortURI(uri,
function (req, uriLong, uriShort) {
@ -852,10 +862,6 @@ function fetchShortenedURI(req) { @@ -852,10 +862,6 @@ function fetchShortenedURI(req) {
applyShortenedURI(req, twister.URIs[req]);
return;
}
if (parseInt(twisterVersion) < 93500) {
console.warn('can\'t fetch URI "' + req + '": daemon is obsolete, version 0.9.35 or higher is required');
return;
}
decodeShortURI(req,
function (req, ret) {

4
js/twister_actions.js

@ -324,6 +324,10 @@ function newRtMsg(postData, msg) { @@ -324,6 +324,10 @@ function newRtMsg(postData, msg) {
function newShortURI(uri, cbFunc, cbReq) {
if (!uri || !defaultScreenName) return;
if (parseInt(twisterVersion) < 93500) {
console.warn('can\'t short URI "' + uri + '": daemon is obsolete, version 0.9.35 or higher is required');
return;
}
for (var i in twister.URIs)
if (twister.URIs[i] === uri) {

6
js/twister_io.js

@ -113,6 +113,12 @@ function dhtget(peerAlias, resource, multi, cbFunc, cbReq, timeoutArgs) { @@ -113,6 +113,12 @@ function dhtget(peerAlias, resource, multi, cbFunc, cbReq, timeoutArgs) {
// the expanded url is returned to callback
// null is passed to callback in case of an error
function decodeShortURI(locator, cbFunc, cbReq, timeoutArgs) {
if (!locator) return;
if (parseInt(twisterVersion) < 93500) {
console.warn('can\'t fetch URI "' + req + '": daemon is obsolete, version 0.9.35 or higher is required');
return;
}
if (_dhtgetPendingMap[locator]) {
_dhtgetAddPending(locator, cbFunc, cbReq);
} else {

Loading…
Cancel
Save