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.isFx && !Zotero.isBookmarklet && !Zotero.isStandalone && Components.classes["@mozilla.org/privatebrowsing;1"]) { if (Zotero.isConnector && await Zotero.Connector_Browser.isIncognito()) {
var pbs = Components.classes["@mozilla.org/privatebrowsing;1"] return
.getService(Components.interfaces.nsIPrivateBrowsingService);
if (pbs.privateBrowsingEnabled) {
return;
}
} }
var translator = this.translator[0]; var translator = this.translator[0];
return Zotero.getSystemInfo().then(function(info) { var info = await Zotero.getSystemInfo();
var postBody = "id=" + encodeURIComponent(translator.translatorID) + var postBody = "id=" + encodeURIComponent(translator.translatorID) +
"&lastUpdated=" + encodeURIComponent(translator.lastUpdated) + "&lastUpdated=" + encodeURIComponent(translator.lastUpdated) +
"&diagnostic=" + encodeURIComponent(info) + "&diagnostic=" + encodeURIComponent(info) +
"&errorData=" + encodeURIComponent(errorString); "&errorData=" + encodeURIComponent(errorString);
return Zotero.HTTP.doPost(ZOTERO_CONFIG.REPOSITORY_URL + "report", postBody); return Zotero.HTTP.doPost(ZOTERO_CONFIG.REPOSITORY_URL + "report", postBody);
});
} }
}.bind(this));
} }
/** /**