A few small bugfixes

This commit is contained in:
Scott Nonnenberg 2021-05-27 13:47:39 -07:00 committed by GitHub
parent d4dc9b8e39
commit ee41e4f71d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 19 deletions

View file

@ -3221,6 +3221,13 @@ export async function startApp(): Promise<void> {
try {
await window.textsecure.storage.protocol.removeAllConfiguration();
// This was already done in the database with removeAllConfiguration; this does it
// for all the conversation models in memory.
window.getConversations().forEach(conversation => {
// eslint-disable-next-line no-param-reassign
delete conversation.attributes.senderKeyInfo;
});
// These two bits of data are important to ensure that the app loads up
// the conversation list, instead of showing just the QR code screen.
window.Signal.Util.Registration.markEverDone();

View file

@ -4863,7 +4863,7 @@ async function removeAllConfiguration(): Promise<void> {
const patch: Partial<ConversationType> = { senderKeyInfo: undefined };
db.transaction(() => {
db.prepare(
db.exec(
`
DELETE FROM identityKeys;
DELETE FROM items;
@ -4873,11 +4873,13 @@ async function removeAllConfiguration(): Promise<void> {
DELETE FROM signedPreKeys;
DELETE FROM unprocessed;
DELETE FROM jobs;
UPDATE conversations SET json = json_patch(json, $patch);
`
).run({
$patch: patch,
});
);
db.prepare('UPDATE conversations SET json = json_patch(json, $patch);').run(
{
patch: JSON.stringify(patch),
}
);
})();
}

View file

@ -1637,7 +1637,7 @@ export default class MessageSender {
// No functions should really call this; since most group sends are now via Sender Key
async sendGroupProto(
providedIdentifiers: Array<string>,
proto: ContentClass | DataMessageClass,
proto: ContentClass,
timestamp = Date.now(),
options?: SendOptionsType
): Promise<CallbackResultType> {
@ -1660,7 +1660,7 @@ export default class MessageSender {
return new Promise((resolve, reject) => {
const silent = true;
const callback = (res: CallbackResultType) => {
res.dataMessage = proto.toArrayBuffer();
res.dataMessage = proto.dataMessage?.toArrayBuffer();
if (res.errors && res.errors.length > 0) {
reject(res);
} else {

View file

@ -249,7 +249,15 @@ export async function sendToGroupViaSenderKey(options: {
`sendToGroupViaSenderKey/${logId}: ${devicesForSenderKey.length} devices for sender key, ${devicesForNormalSend.length} devices for normal send`
);
// 5. Analyze target devices for sender key, determine which have been added or removed
// 5. Ensure we have enough recipients
const senderKeyRecipients = getUuidsFromDevices(devicesForSenderKey);
if (senderKeyRecipients.length < 2) {
throw new Error(
`sendToGroupViaSenderKey/${logId}: Not enough recipients for Sender Key message. Failing over.`
);
}
// 6. Analyze target devices for sender key, determine which have been added or removed
const {
newToMemberDevices,
newToMemberUuids,
@ -261,7 +269,7 @@ export async function sendToGroupViaSenderKey(options: {
isPartialSend
);
// 6. If members have been removed from the group, we need to reset our sender key, then
// 7. If members have been removed from the group, we need to reset our sender key, then
// start over to get a fresh set of target devices.
const keyNeedsReset = Array.from(removedFromMemberUuids).some(
uuid => !conversation.hasMember(uuid)
@ -277,7 +285,7 @@ export async function sendToGroupViaSenderKey(options: {
});
}
// 7. If there are new members or new devices in the group, we need to ensure that they
// 8. If there are new members or new devices in the group, we need to ensure that they
// have our sender key before we send sender key messages to them.
if (newToMemberUuids.length > 0) {
window.log.info(
@ -291,7 +299,7 @@ export async function sendToGroupViaSenderKey(options: {
});
}
// 8. Update memberDevices with both adds and the removals which didn't require a reset.
// 9. Update memberDevices with both adds and the removals which didn't require a reset.
if (removedFromMemberDevices.length > 0 || newToMemberDevices.length > 0) {
const updatedMemberDevices = [
...differenceWith<DeviceType, DeviceType>(
@ -312,14 +320,6 @@ export async function sendToGroupViaSenderKey(options: {
await window.Signal.Data.updateConversation(conversation.attributes);
}
// 9. Ensure we have enough recipients
const senderKeyRecipients = getUuidsFromDevices(devicesForSenderKey);
if (senderKeyRecipients.length < 2) {
throw new Error(
`sendToGroupViaSenderKey/${logId}: Not enough recipients for Sender Key message. Failing over.`
);
}
// 10. Send the Sender Key message!
try {
const messageBuffer = await encryptForSenderKey({