Don't send translator error from connectors reports in private-browsing mode

This commit is contained in:
Adomas Venčkauskas 2017-11-10 11:10:06 +02:00
parent 6b031249ac
commit 08eefeaf57

View File

@ -2193,7 +2193,7 @@ Zotero.Translate.Web.prototype._translateServerComplete = function(statusCode, r
/** /**
* Overload complete to report translation failure * Overload complete to report translation failure
*/ */
Zotero.Translate.Web.prototype.complete = function(returnValue, error) { Zotero.Translate.Web.prototype.complete = async function(returnValue, error) {
// call super // call super
var oldState = this._currentState; var oldState = this._currentState;
var errorString = Zotero.Translate.Base.prototype.complete.apply(this, [returnValue, error]); var errorString = Zotero.Translate.Base.prototype.complete.apply(this, [returnValue, error]);
@ -2204,30 +2204,24 @@ Zotero.Translate.Web.prototype.complete = function(returnValue, error) {
} else { } else {
promise = Zotero.Promise.resolve(Zotero.Prefs.get("reportTranslationFailure")); promise = Zotero.Promise.resolve(Zotero.Prefs.get("reportTranslationFailure"));
} }
var reportTranslationFailure = await promise;
return promise.then(function(reportTranslationFailure) { // Report translation failure if we failed
// Report translation failure if we failed if(oldState == "translate" && errorString && !this._parentTranslator && this.translator.length
if(oldState == "translate" && errorString && !this._parentTranslator && this.translator.length && this.translator[0].inRepository && reportTranslationFailure) {
&& this.translator[0].inRepository && reportTranslationFailure) { // Don't report failure if in private browsing mode
// Don't report failure if in private browsing mode if (Zotero.isConnector && await Zotero.Connector_Browser.isIncognito()) {
if(Zotero.isFx && !Zotero.isBookmarklet && !Zotero.isStandalone && Components.classes["@mozilla.org/privatebrowsing;1"]) { return
var pbs = Components.classes["@mozilla.org/privatebrowsing;1"] }
.getService(Components.interfaces.nsIPrivateBrowsingService);
if (pbs.privateBrowsingEnabled) { var translator = this.translator[0];
return; var info = await Zotero.getSystemInfo();
}
} var postBody = "id=" + encodeURIComponent(translator.translatorID) +
"&lastUpdated=" + encodeURIComponent(translator.lastUpdated) +
var translator = this.translator[0]; "&diagnostic=" + encodeURIComponent(info) +
return Zotero.getSystemInfo().then(function(info) { "&errorData=" + encodeURIComponent(errorString);
var postBody = "id=" + encodeURIComponent(translator.translatorID) + return Zotero.HTTP.doPost(ZOTERO_CONFIG.REPOSITORY_URL + "report", postBody);
"&lastUpdated=" + encodeURIComponent(translator.lastUpdated) + }
"&diagnostic=" + encodeURIComponent(info) +
"&errorData=" + encodeURIComponent(errorString);
return Zotero.HTTP.doPost(ZOTERO_CONFIG.REPOSITORY_URL + "report", postBody);
});
}
}.bind(this));
} }
/** /**