[feat] display the mixnet status on incomming emails
authorRuben Pollan <meskio@sindominio.net>
Tue, 25 Jul 2017 16:56:00 +0000 (18:56 +0200)
committerRuben Pollan <meskio@sindominio.net>
Thu, 27 Jul 2017 10:48:58 +0000 (12:48 +0200)
Add support for X-Leap-Mixnet header.

service/src/pixelated/adapter/mailstore/leap_mailstore.py
web-ui/app/js/mail_view/ui/mail_view.js
web-ui/app/locales/en_US/translation.json
web-ui/app/scss/views/_security-labels.scss
web-ui/app/templates/mails/full_view.hbs

index 288223d..cfda2e5 100644 (file)
@@ -88,7 +88,8 @@ class LeapMail(Mail):
 
     @property
     def security_casing(self):
-        casing = dict(imprints=self._signature_information(), locks=[])
+        casing = dict(imprints=self._signature_information(), locks=[],
+                      mixnet=self._mixnet())
         if self._encrypted() == "decrypted":
             casing["locks"] = [{"state": "valid"}]
         return casing
@@ -106,6 +107,13 @@ class LeapMail(Mail):
             else:
                 return []
 
+    def _mixnet(self):
+        mixnet = self.headers.get("X-Leap-Mixnet", "")
+        if mixnet == "":
+            return []
+
+        return [{"state": "valid", "mixnet": mixnet}]
+
     @property
     def raw(self):
         result = u''
index 029707c..48672c9 100644 (file)
@@ -51,6 +51,7 @@ define(
         data.mail.security_casing = data.mail.security_casing || {};
         signed = this.checkSigned(data.mail);
         encrypted = this.checkEncrypted(data.mail);
+        mixnet = this.checkMixnet(data.mail);
         attachments = data.mail.attachments.map(function (attachment) {
             attachment.received = true;
             return attachment;
@@ -68,6 +69,7 @@ define(
           ident: data.mail.ident,
           tags: data.mail.tags,
           encryptionStatus: encrypted,
+          mixnetStatus: mixnet,
           signatureStatus: signed,
           attachments: attachments
         }));
@@ -186,6 +188,21 @@ define(
         return SIGNED_FLAG;
       };
 
+      this.checkMixnet = function(mail) {
+
+        var MIXNET_FLAG = {
+          cssClass: 'security-status__label--mixnet',
+          label: 'mixnet',
+          tooltipText: 'mixnet-label-tooltip'
+        };
+
+        if(_.any(mail.security_casing.mixnet, function(mixnet) { return mixnet.state === 'valid'; })) {
+            return MIXNET_FLAG;
+        }
+
+        return null;
+      };
+
       this.isNotTrusted = function(mail){
         return _.any(mail.security_casing.imprints, function(imprint) {
           if(_.isNull(imprint.seal)){
index 6ca7228..66b9e01 100644 (file)
@@ -43,6 +43,7 @@
     "not-encrypted-label-tooltip": "This message is not encrypted.",
     "not-signed-label-tooltip": "The sender could not be verified.",
     "signed-label-tooltip": "You are communicating with the real sender.",
+    "mixnet-label-tooltip": "This message was sent using panoramix mixnet.",
     "sending-mail": "Sending...",
     "mail-sent": "Your message was sent!",
     "mail-not-sent": "Error,  message not sent:",
index 5319eb1..5ccf613 100644 (file)
         content: "\f05e";
       }
     }
+
+    &--mixnet {
+      &:before {
+        content: "\f023";
+      }
+  }
   }
 }
index 0068b7f..98d5551 100644 (file)
               {{t encryptionStatus.label }}
             </span>
             {{/if}}
+            {{#if mixnetStatus}}
+            <span class="security-status__label {{ mixnetStatus.cssClass }}" data-label="{{t mixnetStatus.tooltipText }}">
+              {{t mixnetStatus.label }}
+            </span>
+            {{/if}}
         </div>
 
         <div class="mail-read-view__header-recipients">