1
0
mirror of https://github.com/moparisthebest/mail synced 2024-12-23 07:48:48 -05:00

[WO-99] set address label in reader depending on public key availability

This commit is contained in:
Tankred Hase 2013-12-04 16:35:53 +01:00
parent 0eecbb0d20
commit 2e4e59101b
2 changed files with 35 additions and 3 deletions

View File

@ -28,7 +28,13 @@ define(function(require) {
};
$scope.getFingerprint = function(address) {
$scope.fingerprint = 'Fingerprint cannot be displayed. Public key not found for that user.';
keychain.getReceiverPublicKey(address, function(err, pubkey) {
if (err) {
$scope.onError(err);
return;
}
var fpr = crypto.getFingerprint(pubkey.publicKey);
var formatted = fpr.slice(0, 4) + ' ' + fpr.slice(4, 8) + ' ' + fpr.slice(8, 12) + ' ' + fpr.slice(12, 16) + ' ' + fpr.slice(16, 20) + ' ' + fpr.slice(20, 24) + ' ' + fpr.slice(24, 28) + ' ' + fpr.slice(28, 32) + ' ' + fpr.slice(32, 36) + ' ' + fpr.slice(36);
@ -36,6 +42,32 @@ define(function(require) {
$scope.$apply();
});
};
$scope.$watch('state.mailList.selected', function() {
var mail = $scope.state.mailList.selected;
// display sender security status
mail.from.forEach(checkPublicKey);
// display recipient security status
mail.to.forEach(checkPublicKey);
});
function checkPublicKey(user) {
user.secure = undefined;
keychain.getReceiverPublicKey(user.address, function(err, pubkey) {
if (err) {
$scope.onError(err);
return;
}
if (pubkey && pubkey.publicKey) {
user.secure = true;
} else {
user.secure = false;
}
$scope.$apply();
});
}
};
//

View File

@ -9,14 +9,14 @@
<p class="subject" ng-click="state.read.toggle(false)">{{state.mailList.selected.subject || 'No subject'}}</p>
<p class="date">{{state.mailList.selected.sentDate | date:'EEEE, MMM d, yyyy h:mm a'}}</p>
<p class="address">
From: <span class="label" data-icon-append="&#xe009;" ng-repeat="f in state.mailList.selected.from" ng-mouseover="getFingerprint(f.address)" popover="#fingerprint-info">{{f.name || f.address}}</span>
From: <span ng-repeat="u in state.mailList.selected.from" class="label" ng-class="{'label-primary': u.secure === false}" data-icon-append="{{(u.secure === false) ? '&#xe001;' : (u.secure === true) ? '&#xe009;' : ''}}" ng-mouseover="getFingerprint(u.address)" popover="#fingerprint-info">{{u.name || u.address}}</span>
</p>
<p class="address">
To: <span class="label" data-icon-append="&#xe009;" ng-repeat="t in state.mailList.selected.to" ng-mouseover="getFingerprint(t.address)" popover="#fingerprint-info">{{t.address}}</span>
To: <span ng-repeat="u in state.mailList.selected.to" class="label" ng-class="{'label-primary': u.secure === false}" data-icon-append="{{(u.secure === false) ? '&#xe001;' : (u.secure === true) ? '&#xe009;' : ''}}" ng-mouseover="getFingerprint(u.address)" popover="#fingerprint-info">{{u.name || u.address}}</span>
</p>
<div ng-switch="state.mailList.selected.cc !== undefined">
<p class="address" ng-switch-when="true">
CC: <span class="label" ng-repeat="t in state.mailList.selected.cc" ng-mouseover="getFingerprint(t.address)" popover="fingerprint" popover-title="Fingerprint">{{t.address}}</span>
CC: <span ng-repeat="u in state.mailList.selected.cc" class="label" ng-class="{'label-primary': u.secure === false}" data-icon-append="{{(u.secure === false) ? '&#xe001;' : (u.secure === true) ? '&#xe009;' : ''}}" ng-mouseover="getFingerprint(u.address)" popover="#fingerprint-info">{{u.name || u.address}}</span>
</p>
</div>
</div><!--/.headers-->