Browse Source

P4TB-393: Make privacy handshake update colour correctly for sent messages.

master
Jörg Knobloch 1 year ago
parent
commit
8f93f37a74
4 changed files with 22 additions and 13 deletions
  1. +9
    -9
      addon/content/dialogs/privacy_status.js
  2. +1
    -1
      addon/content/modules/pEp.js
  3. +1
    -0
      addon/content/pepmessengercompose.js
  4. +11
    -3
      addon/content/pepmsghdrview.js

+ 9
- 9
addon/content/dialogs/privacy_status.js View File

@ -97,11 +97,11 @@ var pEpPrivacyStatus = {
});
},
executeHandler(handler) {
executeHandler(handler, other) {
return () => {
pEpController.synchronise(handler());
pEpController.synchronise(handler(other));
pEpController.log.info(`Notify pEp-trust-changed for ${this.caller}`);
Services.obs.notifyObservers(null, "pEp-trust-changed", this.caller);
Services.obs.notifyObservers(null, "pEp-trust-changed", JSON.stringify({ caller: this.caller, other }));
window.close();
};
},
@ -138,8 +138,8 @@ var pEpPrivacyStatus = {
},
handlers: {
// Reset Trust is apparently not required.
// "reset-trust": this.executeHandler(this.handshake.actionResetTrust.bind(this.handshake, otherIdentity)),
"button#reset-user": this.executeHandler(this.handshake.actionResetUser.bind(this.handshake, otherIdentity)),
// "reset-trust": this.executeHandler(this.handshake.actionResetTrust.bind(this.handshake), otherIdentity),
"button#reset-user": this.executeHandler(this.handshake.actionResetUser.bind(this.handshake), otherIdentity),
},
});
} else if (color == "yellow") {
@ -173,9 +173,9 @@ var pEpPrivacyStatus = {
"div#Trustwords": "none",
},
handlers: {
"button#accept-trust": this.executeHandler(this.handshake.actionTrustKey.bind(this.handshake, otherIdentity)),
"button#reject-trust": this.executeHandler(this.handshake.actionMistrustKey.bind(this.handshake, otherIdentity)),
"button#reset-user": this.executeHandler(this.handshake.actionResetUser.bind(this.handshake, otherIdentity)),
"button#accept-trust": this.executeHandler(this.handshake.actionTrustKey.bind(this.handshake), otherIdentity),
"button#reject-trust": this.executeHandler(this.handshake.actionMistrustKey.bind(this.handshake), otherIdentity),
"button#reset-user": this.executeHandler(this.handshake.actionResetUser.bind(this.handshake), otherIdentity),
"checkbox#full-trustwords":
this.executeHandler2(this.handshake.fullTrustwords, this.ownIdentity, otherIdentity),
"menulist#language-selector":
@ -192,7 +192,7 @@ var pEpPrivacyStatus = {
adjustments: {
},
handlers: {
"button#reset-user": this.executeHandler(this.handshake.actionResetUser.bind(this.handshake, otherIdentity)),
"button#reset-user": this.executeHandler(this.handshake.actionResetUser.bind(this.handshake), otherIdentity),
},
});
}


+ 1
- 1
addon/content/modules/pEp.js View File

@ -255,7 +255,7 @@ class pEp {
}
async reEvaluateMessageRating(message, keyList, oldRating) {
this.log.info("pEp: reEvaluateMessageRating()");
this.log.info("pEp: reEvaluateMessageRating()", message.from, keyList, oldRating);
return this.adapter.re_evaluate_message_rating(message, keyList, oldRating);
}


+ 1
- 0
addon/content/pepmessengercompose.js View File

@ -315,6 +315,7 @@ var pEpComposer = {
},
observe(aSubject, aTopic, aData) {
pEpController.log.info("compose observer called", JSON.parse(aData));
const msgCompFields = this.win.gMsgCompose.compFields;
const [from, to, cc, bcc, replyTo] = this.getAddresses(this.win.gCurrentIdentity, msgCompFields);
if (!from || !to) return;


+ 11
- 3
addon/content/pepmsghdrview.js View File

@ -232,13 +232,15 @@ var pEpHdrView = {
},
observe(aSubject, aTopic, aData) {
let data = JSON.parse(aData);
pEpController.log.info("view observer called", data);
const msgHdr = this.win.gFolderDisplay.selectedMessage;
if (!msgHdr) return;
// We shouldn't update the message which is selected if the handshake was launched
// from a compose window or a stand-alone window for a different message.
// eslint-disable-next-line prefer-template
if (aData != ("view-" + msgHdr.messageId)) return;
if (data.caller != ("view-" + msgHdr.messageId)) return;
const parser = Cc["@mozilla.org/messenger/headerparser;1"].createInstance(Ci.nsIMsgHeaderParser);
const fromHeader = parser.parseEncodedHeader(msgHdr.author, "utf-8");
@ -274,8 +276,14 @@ var pEpHdrView = {
keyList = keyList.split(",");
// Make a fake message, we only need the from.
const from = TbContacts.getpEpIdentity(fromHeader[0]);
let message = new pEp.Message(msgHdr.messageId, "test", "", from);
let message = new pEp.Message(msgHdr.messageId, "test", "", data.other);
// Move the other guys FPR to the front, the engine likes it this way.
let fpr = data.other.fpr;
let ind = keyList.indexOf(fpr);
if (ind > 0) {
keyList[ind] = keyList[0];
keyList[0] = fpr;
}
ratingPromise = pEpController.reEvaluateMessageRating(message, keyList, oldRating);
isDraftorTemplate = false;
}


Loading…
Cancel
Save