Add isBlocking/isNonBlockingApprovalRequired
These analyse the identity key record and user preferences to determine whether a key requires approval for sending. // FREEBIE
This commit is contained in:
parent
22e907a8d4
commit
4d4dd3341f
1 changed files with 11 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
;(function() {
|
||||
'use strict';
|
||||
var TIMESTAMP_THRESHOLD = 5 * 1000; // 5 seconds
|
||||
|
||||
var StaticByteBufferProto = new dcodeIO.ByteBuffer().__proto__;
|
||||
var StaticArrayBufferProto = new ArrayBuffer().__proto__;
|
||||
|
@ -343,6 +344,16 @@
|
|||
});
|
||||
});
|
||||
},
|
||||
isBlockingApprovalRequired: function(identityKey) {
|
||||
return (!identityKey.get('firstUse')
|
||||
&& storage.get('safety-numbers-approval', true)
|
||||
&& !identityKey.get('blockingApproval'));
|
||||
},
|
||||
isNonBlockingApprovalRequired: function(identityKey) {
|
||||
return (!identityKey.get('firstUse')
|
||||
&& Date.now() - identityKey.get('timestamp') < TIMESTAMP_THRESHOLD
|
||||
&& !identityKey.get('nonblockingApproval'));
|
||||
},
|
||||
removeIdentityKey: function(number) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var identityKey = new IdentityKey({id: number});
|
||||
|
|
Loading…
Reference in a new issue