"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "ts/sql/Server.ts" between
Signal-Desktop-1.35.2.tar.gz and Signal-Desktop-1.36.1.tar.gz

About: Signal-Desktop is a cross-platform encrypted messaging service (also available for mobile devices).

Server.ts  (Signal-Desktop-1.35.2):Server.ts  (Signal-Desktop-1.36.1)
skipping to change at line 13 skipping to change at line 13
import { join } from 'path'; import { join } from 'path';
import mkdirp from 'mkdirp'; import mkdirp from 'mkdirp';
import rimraf from 'rimraf'; import rimraf from 'rimraf';
import PQueue from 'p-queue'; import PQueue from 'p-queue';
import sql from '@journeyapps/sqlcipher'; import sql from '@journeyapps/sqlcipher';
import { app, clipboard, dialog } from 'electron'; import { app, clipboard, dialog } from 'electron';
import { redactAll } from '../../js/modules/privacy'; import { redactAll } from '../../js/modules/privacy';
import { remove as removeUserConfig } from '../../app/user_config'; import { remove as removeUserConfig } from '../../app/user_config';
import { combineNames } from '../util/combineNames'; import { combineNames } from '../util/combineNames';
import { GroupV2MemberType } from '../model-types.d';
import { LocaleMessagesType } from '../types/I18N'; import { LocaleMessagesType } from '../types/I18N';
import pify from 'pify'; import pify from 'pify';
import { v4 as generateUUID } from 'uuid'; import { v4 as generateUUID } from 'uuid';
import { import {
Dictionary, Dictionary,
forEach, forEach,
fromPairs, fromPairs,
isNumber, isNumber,
isObject, isObject,
skipping to change at line 107 skipping to change at line 108
removeAllSessions, removeAllSessions,
getAllSessions, getAllSessions,
getConversationCount, getConversationCount,
saveConversation, saveConversation,
saveConversations, saveConversations,
getConversationById, getConversationById,
updateConversation, updateConversation,
updateConversations, updateConversations,
removeConversation, removeConversation,
eraseStorageIdFromConversations, eraseStorageServiceStateFromConversations,
getAllConversations, getAllConversations,
getAllConversationIds, getAllConversationIds,
getAllPrivateConversations, getAllPrivateConversations,
getAllGroupsInvolvingId, getAllGroupsInvolvingId,
searchConversations, searchConversations,
searchMessages, searchMessages,
searchMessagesInConversation, searchMessagesInConversation,
getMessageCount, getMessageCount,
skipping to change at line 2073 skipping to change at line 2074
async function saveConversation( async function saveConversation(
data: ConversationType, data: ConversationType,
instance = getInstance() instance = getInstance()
) { ) {
const { const {
active_at, active_at,
e164, e164,
groupId, groupId,
id, id,
members, members,
membersV2,
name, name,
profileFamilyName, profileFamilyName,
profileName, profileName,
type, type,
uuid, uuid,
} = data; } = data;
// prettier-ignore
const membersList = membersV2
? membersV2.map((item: GroupV2MemberType) => item.conversationId).join(' ')
: members
? members.join(' ')
: null;
await instance.run( await instance.run(
`INSERT INTO conversations ( `INSERT INTO conversations (
id, id,
json, json,
e164, e164,
uuid, uuid,
groupId, groupId,
active_at, active_at,
skipping to change at line 2122 skipping to change at line 2131
{ {
$id: id, $id: id,
$json: objectToJSON(data), $json: objectToJSON(data),
$e164: e164, $e164: e164,
$uuid: uuid, $uuid: uuid,
$groupId: groupId, $groupId: groupId,
$active_at: active_at, $active_at: active_at,
$type: type, $type: type,
$members: members ? members.join(' ') : null, $members: membersList,
$name: name, $name: name,
$profileName: profileName, $profileName: profileName,
$profileFamilyName: profileFamilyName, $profileFamilyName: profileFamilyName,
$profileFullName: combineNames(profileName, profileFamilyName), $profileFullName: combineNames(profileName, profileFamilyName),
} }
); );
} }
async function saveConversations( async function saveConversations(
arrayOfConversations: Array<ConversationType> arrayOfConversations: Array<ConversationType>
skipping to change at line 2159 skipping to change at line 2168
} }
saveConversations.needsSerial = true; saveConversations.needsSerial = true;
async function updateConversation(data: ConversationType) { async function updateConversation(data: ConversationType) {
const db = getInstance(); const db = getInstance();
const { const {
id, id,
active_at, active_at,
type, type,
members, members,
membersV2,
name, name,
profileName, profileName,
profileFamilyName, profileFamilyName,
e164, e164,
uuid, uuid,
} = data; } = data;
// prettier-ignore
const membersList = membersV2
? membersV2.map((item: GroupV2MemberType) => item.conversationId).join(' ')
: members
? members.join(' ')
: null;
await db.run( await db.run(
`UPDATE conversations SET `UPDATE conversations SET
json = $json, json = $json,
e164 = $e164, e164 = $e164,
uuid = $uuid, uuid = $uuid,
active_at = $active_at, active_at = $active_at,
type = $type, type = $type,
members = $members, members = $members,
skipping to change at line 2190 skipping to change at line 2207
WHERE id = $id;`, WHERE id = $id;`,
{ {
$id: id, $id: id,
$json: objectToJSON(data), $json: objectToJSON(data),
$e164: e164, $e164: e164,
$uuid: uuid, $uuid: uuid,
$active_at: active_at, $active_at: active_at,
$type: type, $type: type,
$members: members ? members.join(' ') : null, $members: membersList,
$name: name, $name: name,
$profileName: profileName, $profileName: profileName,
$profileFamilyName: profileFamilyName, $profileFamilyName: profileFamilyName,
$profileFullName: combineNames(profileName, profileFamilyName), $profileFullName: combineNames(profileName, profileFamilyName),
} }
); );
} }
async function updateConversations(array: Array<ConversationType>) { async function updateConversations(array: Array<ConversationType>) {
const db = getInstance(); const db = getInstance();
await db.run('BEGIN TRANSACTION;'); await db.run('BEGIN TRANSACTION;');
skipping to change at line 2246 skipping to change at line 2263
$id: id, $id: id,
}); });
if (!row) { if (!row) {
return null; return null;
} }
return jsonToObject(row.json); return jsonToObject(row.json);
} }
async function eraseStorageIdFromConversations() { async function eraseStorageServiceStateFromConversations() {
const db = getInstance(); const db = getInstance();
await db.run( await db.run(
`UPDATE conversations SET `UPDATE conversations SET
json = json_remove(json, '$.storageID'); json = json_remove(json, '$.storageID', '$.needsStorageServiceSync', '$.un knownFields');
` `
); );
} }
async function getAllConversations() { async function getAllConversations() {
const db = getInstance(); const db = getInstance();
const rows = await db.all('SELECT json FROM conversations ORDER BY id ASC;'); const rows = await db.all('SELECT json FROM conversations ORDER BY id ASC;');
return map(rows, row => jsonToObject(row.json)); return map(rows, row => jsonToObject(row.json));
} }
 End of changes. 10 change blocks. 
5 lines changed or deleted 22 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)