Note to Self timer fixes for bugs reported by beta users

This commit is contained in:
Scott Nonnenberg 2019-02-14 09:36:24 -08:00
parent 7c4ba5446c
commit af40ceda6c
3 changed files with 34 additions and 7 deletions

View file

@ -1257,10 +1257,24 @@
const sendOptions = this.getSendOptions();
let promise;
if (this.isMe()) {
const dataMessage = await textsecure.messaging.getMessageProto(
this.get('id'),
null,
[],
null,
[],
message.get('sent_at'),
expireTimer,
profileKey
);
return message.sendSyncMessageOnly(dataMessage);
}
if (this.get('type') === 'private') {
promise = textsecure.messaging.sendExpirationTimerUpdateToNumber(
this.get('id'),
this.get('expireTimer'),
expireTimer,
message.get('sent_at'),
profileKey,
sendOptions
@ -1269,7 +1283,7 @@
promise = textsecure.messaging.sendExpirationTimerUpdateToGroup(
this.get('id'),
this.getRecipients(),
this.get('expireTimer'),
expireTimer,
message.get('sent_at'),
profileKey,
sendOptions

View file

@ -632,7 +632,7 @@
// back to the conversation's current recipients
const phoneNumbers = this.isIncoming()
? [this.get('source')]
: this.get('sent_to') || this.conversation.getRecipients();
: this.get('sent_to') || this.getConversation().getRecipients();
// This will make the error message for outgoing key errors a bit nicer
const allErrors = (this.get('errors') || []).map(error => {
@ -1062,8 +1062,15 @@
this.set({ dataMessage });
try {
await this.sendSyncMessage();
const result = await this.sendSyncMessage();
this.set({
// These are the same as a normal send
sent_to: [this.OUR_NUMBER],
sent: true,
expirationStartTimestamp: Date.now(),
unidentifiedDeliveries: result ? result.unidentifiedDeliveries : null,
// These are unique to a Note to Self message - immediately read/delivered
delivered_to: [this.OUR_NUMBER],
read_by: [this.OUR_NUMBER],
});

View file

@ -846,7 +846,7 @@ MessageSender.prototype = {
)
);
const sendToContact = deleteAllSessions(number)
const sendToContactPromise = deleteAllSessions(number)
.catch(logError('resetSession/deleteAllSessions1 error:'))
.then(() => {
window.log.info(
@ -866,8 +866,14 @@ MessageSender.prototype = {
)
);
const myNumber = textsecure.storage.user.getNumber();
// We already sent the reset session to our other devices in the code above!
if (number === myNumber) {
return sendToContactPromise;
}
const buffer = proto.toArrayBuffer();
const sendSync = this.sendSyncMessage(
const sendSyncPromise = this.sendSyncMessage(
buffer,
timestamp,
number,
@ -877,7 +883,7 @@ MessageSender.prototype = {
options
).catch(logError('resetSession/sendSync error:'));
return Promise.all([sendToContact, sendSync]);
return Promise.all([sendToContactPromise, sendSyncPromise]);
},
sendMessageToGroup(