Merge pull request #987 from loki-project/open-group-fix

Fix messages not being created properly in open groups
pull/991/head
Vince 5 years ago committed by GitHub
commit 0f06046247
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1946,6 +1946,10 @@
}) {
return async event => {
const { data, confirm } = event;
if (!data) {
window.log.warn('Invalid data passed to createMessageHandler.', event);
return confirm();
}
const messageDescriptor = getMessageDescriptor(data);
@ -1968,36 +1972,38 @@
messageDescriptor.id
);
let message;
if (
const { source } = data;
// Note: This only works currently because we have a 1 device limit
// When we change that, the check below needs to change too
const ourNumber = textsecure.storage.user.getNumber();
const primaryDevice = window.storage.get('primaryDevicePubKey');
const isOurDevice =
source && (source === ourNumber || source === primaryDevice);
const isPublicChatMessage =
messageDescriptor.type === 'group' &&
descriptorId.match(/^publicChat:/)
) {
// Note: This only works currently because we have a 1 device limit
// When we change that, the check below needs to change too
const ourNumber = textsecure.storage.user.getNumber();
const primaryDevice = window.storage.get('primaryDevicePubKey');
const { source } = data;
if (source && (source === ourNumber || source === primaryDevice)) {
// Public chat messages from ourselves should be outgoing
message = await createSentMessage(data);
}
descriptorId.match(/^publicChat:/);
if (isPublicChatMessage && isOurDevice) {
// Public chat messages from ourselves should be outgoing
message = await createSentMessage(data);
} else {
message = await createMessage(data);
}
const isDuplicate = await isMessageDuplicate(message);
if (isDuplicate) {
// RSS expects duplciates, so squelch log
if (!descriptorId.match(/^rss:/)) {
window.log.warn('Received duplicate message', message.idForLogging());
}
return event.confirm();
return confirm();
}
await ConversationController.getOrCreateAndWait(
messageDescriptor.id,
messageDescriptor.type
);
return message.handleDataMessage(data.message, event.confirm, {
return message.handleDataMessage(data.message, confirm, {
initialLoadComplete,
});
};

@ -103,8 +103,11 @@ class LokiFileServerInstance {
if (!Array.isArray(authorisations)) {
return;
}
const validAuthorisations = authorisations.filter(
a => a && typeof auth === 'object'
);
await Promise.all(
authorisations.map(async auth => {
validAuthorisations.map(async auth => {
// only skip, if in secondary search mode
if (isRequest && auth.secondaryDevicePubKey !== user.username) {
// this is not the authorization we're looking for

@ -147,7 +147,9 @@
({ authorisations } = primaryDeviceMapping);
}
}
return authorisations || [];
// filter out any invalid authorisations
return authorisations.filter(a => a && typeof a === 'object') || [];
}
// if the device is a secondary device,
@ -168,6 +170,10 @@
}
async function savePairingAuthorisation(authorisation) {
if (!authorisation) {
return;
}
// Ensure that we have a conversation for all the devices
const conversation = await ConversationController.getOrCreateAndWait(
authorisation.secondaryDevicePubKey,

Loading…
Cancel
Save