Merge pull request #1349 from Bilb/fix-ssk-groups

pull/1351/head
Audric Ackermann 5 years ago committed by GitHub
commit e9ad798bcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -812,6 +812,7 @@ const LOKI_SCHEMA_VERSIONS = [
updateToLokiSchemaVersion6, updateToLokiSchemaVersion6,
updateToLokiSchemaVersion7, updateToLokiSchemaVersion7,
updateToLokiSchemaVersion8, updateToLokiSchemaVersion8,
updateToLokiSchemaVersion9,
]; ];
async function updateToLokiSchemaVersion1(currentVersion, instance) { async function updateToLokiSchemaVersion1(currentVersion, instance) {
@ -1075,6 +1076,26 @@ async function updateToLokiSchemaVersion8(currentVersion, instance) {
console.log('updateToLokiSchemaVersion8: success!'); console.log('updateToLokiSchemaVersion8: success!');
} }
async function updateToLokiSchemaVersion9(currentVersion, instance) {
if (currentVersion >= 9) {
return;
}
console.log('updateToLokiSchemaVersion9: starting...');
await instance.run('BEGIN TRANSACTION;');
await removePrefixFromGroupConversations(instance);
await instance.run(
`INSERT INTO loki_schema (
version
) values (
9
);`
);
await instance.run('COMMIT TRANSACTION;');
console.log('updateToLokiSchemaVersion9: success!');
}
async function updateLokiSchema(instance) { async function updateLokiSchema(instance) {
const result = await instance.get( const result = await instance.get(
"SELECT name FROM sqlite_master WHERE type = 'table' AND name='loki_schema';" "SELECT name FROM sqlite_master WHERE type = 'table' AND name='loki_schema';"
@ -3039,3 +3060,39 @@ async function removeKnownAttachments(allAttachments) {
return Object.keys(lookup); return Object.keys(lookup);
} }
async function removePrefixFromGroupConversations(instance) {
const rows = await instance.all(
`SELECT json FROM conversations WHERE
type = 'group' AND
id LIKE '__textsecure_group__!%';`
);
const objs = map(rows, row => jsonToObject(row.json));
await Promise.all(
objs.map(async o => {
const oldId = o.id;
const newId = oldId.replace('__textsecure_group__!', '');
console.log(`migrating conversation, ${oldId} to ${newId}`);
const morphedObject = {
...o,
id: newId,
};
await instance.run(
`UPDATE ${CONVERSATIONS_TABLE} SET
id = $newId,
json = $json
WHERE id = $oldId;`,
{
$newId: newId,
$json: objectToJSON(morphedObject),
$oldId: oldId,
}
);
})
);
}

@ -1283,10 +1283,8 @@
(dataMessage.attachments && dataMessage.attachments.length)) (dataMessage.attachments && dataMessage.attachments.length))
); );
const shouldNotifyPushServer = const shouldNotifyPushServer =
hasBodyOrAttachments && hasBodyOrAttachments && isSessionOrClosedMessage;
isSessionOrClosedMessage &&
sentMessage.ttl ===
window.libsession.Constants.TTL_DEFAULT.REGULAR_MESSAGE;
if (shouldNotifyPushServer) { if (shouldNotifyPushServer) {
// notify the push notification server if needed // notify the push notification server if needed
if (!wrappedEnvelope) { if (!wrappedEnvelope) {

@ -490,7 +490,7 @@ if (config.environment.includes('test-integration')) {
useOnionRequests: false, useOnionRequests: false,
useFileOnionRequests: false, useFileOnionRequests: false,
debugMessageLogs: true, debugMessageLogs: true,
enableSenderKeys: true, enableSenderKeys: false,
useMultiDevice: false, useMultiDevice: false,
}; };
/* eslint-disable global-require, import/no-extraneous-dependencies */ /* eslint-disable global-require, import/no-extraneous-dependencies */

@ -644,10 +644,11 @@ export async function handleMessageEvent(event: MessageEvent): Promise<void> {
// - group.id if it is a group message // - group.id if it is a group message
let conversationId = id; let conversationId = id;
if (isGroupMessage) { if (isGroupMessage) {
/* handle one part of the group logic here: // remove the prefix from the source object so this is correct for all other
handle requesting info of a new group, message.group.id = message.group.id.replace(
dropping an admin only update from a non admin, ... PubKey.PREFIX_GROUP_TEXTSECURE,
*/ ''
);
conversationId = message.group.id; conversationId = message.group.id;
} }

Loading…
Cancel
Save