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

This commit is contained in:
Simon Grim 2016-03-22 17:43:04 +05:00
parent 3e92986db0
commit ee7f84d2b6
3 changed files with 20 additions and 4 deletions

View File

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

View File

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

View File

@ -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 {