|
|
|
@ -76,7 +76,7 @@
|
|
|
|
|
return {
|
|
|
|
|
unreadCount: 0,
|
|
|
|
|
verified: textsecure.storage.protocol.VerifiedStatus.DEFAULT,
|
|
|
|
|
keysPending: true
|
|
|
|
|
keyExchangeStatus: 'none'
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
@ -398,29 +398,36 @@
|
|
|
|
|
return contact.isVerified();
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
isKeysPending() {
|
|
|
|
|
if (this.isPrivate()) {
|
|
|
|
|
if (this.isMe()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
const keysPending = this.get('keysPending');
|
|
|
|
|
if (keysPending === undefined) {
|
|
|
|
|
keysPending = true;
|
|
|
|
|
}
|
|
|
|
|
return keysPending;
|
|
|
|
|
getKeyExchangeStatus() {
|
|
|
|
|
return this.get('keyExchangeStatus') || 'none';
|
|
|
|
|
},
|
|
|
|
|
isKeyExchangeCompleted() {
|
|
|
|
|
if (!this.isPrivate()) {
|
|
|
|
|
throw new Error(
|
|
|
|
|
'isKeyExchangeCompleted not implemented for groups'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new Error(
|
|
|
|
|
'isKeysPending not implemented for groups'
|
|
|
|
|
);
|
|
|
|
|
if (this.isMe()) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this.getKeyExchangeStatus() == 'completed';
|
|
|
|
|
},
|
|
|
|
|
setKeysPending(keysPending) {
|
|
|
|
|
if (typeof keysPending !== 'boolean') {
|
|
|
|
|
setKeyExchangeStatus(status) {
|
|
|
|
|
if (typeof status !== 'string') {
|
|
|
|
|
throw new Error(
|
|
|
|
|
'setKeyExchangeStatus expects a string'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
status = status.toLowerCase();
|
|
|
|
|
|
|
|
|
|
if (['none', 'ongoing', 'completed'].indexOf(status) < 0) {
|
|
|
|
|
throw new Error(
|
|
|
|
|
'setKeysPending expects a boolean'
|
|
|
|
|
'unknown string value given to setKeyExchangeStatus'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
this.set({ keysPending });
|
|
|
|
|
this.set({ keyExchangeStatus: status });
|
|
|
|
|
},
|
|
|
|
|
isUnverified() {
|
|
|
|
|
if (this.isPrivate()) {
|
|
|
|
|