Support for new GroupV2 groups

This commit is contained in:
Scott Nonnenberg 2020-09-08 19:25:05 -07:00
parent 1ce0959fa1
commit 7a02cc815d
53 changed files with 7326 additions and 839 deletions

View file

@ -10,6 +10,7 @@ const APP_ROOT_PATH = path.join(__dirname, '..', '..', '..');
const PHONE_NUMBER_PATTERN = /\+\d{7,12}(\d{3})/g;
const UUID_PATTERN = /[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{9}([0-9A-F]{3})/gi;
const GROUP_ID_PATTERN = /(group\()([^)]+)(\))/g;
const GROUP_V2_ID_PATTERN = /(groupv2\()([^=)]+)(=?=?\))/g;
const REDACTION_PLACEHOLDER = '[REDACTED]';
// _redactPath :: Path -> String -> String
@ -80,11 +81,21 @@ exports.redactGroupIds = text => {
throw new TypeError("'text' must be a string");
}
return text.replace(
GROUP_ID_PATTERN,
(match, before, id, after) =>
`${before}${REDACTION_PLACEHOLDER}${removeNewlines(id).slice(-3)}${after}`
);
return text
.replace(
GROUP_ID_PATTERN,
(match, before, id, after) =>
`${before}${REDACTION_PLACEHOLDER}${removeNewlines(id).slice(
-3
)}${after}`
)
.replace(
GROUP_V2_ID_PATTERN,
(match, before, id, after) =>
`${before}${REDACTION_PLACEHOLDER}${removeNewlines(id).slice(
-3
)}${after}`
);
};
// redactSensitivePaths :: String -> String

View file

@ -9,6 +9,8 @@ const {
const Data = require('../../ts/sql/Client').default;
const Emojis = require('./emojis');
const EmojiLib = require('../../ts/components/emoji/lib');
const Groups = require('../../ts/groups');
const GroupChange = require('../../ts/groupChange');
const IndexedDB = require('./indexeddb');
const Notifications = require('../../ts/notifications');
const OS = require('../../ts/OS');
@ -108,6 +110,9 @@ const { IdleDetector } = require('./idle_detector');
const MessageDataMigrator = require('./messages_data_migrator');
// Processes / Services
const {
initializeGroupCredentialFetcher,
} = require('../../ts/services/groupCredentialFetcher');
const {
initializeNetworkObserver,
} = require('../../ts/services/networkObserver');
@ -333,6 +338,7 @@ exports.setup = (options = {}) => {
calling,
eraseAllStorageServiceState,
handleUnknownRecords,
initializeGroupCredentialFetcher,
initializeNetworkObserver,
initializeUpdateListener,
notify,
@ -378,6 +384,8 @@ exports.setup = (options = {}) => {
Data,
Emojis,
EmojiLib,
Groups,
GroupChange,
IndexedDB,
LinkPreviews,
Metadata,

View file

@ -1,16 +1,12 @@
/* global crypto, window */
/* global window */
const { isFunction, isNumber } = require('lodash');
const {
arrayBufferToBase64,
base64ToArrayBuffer,
computeHash,
} = require('../../../ts/Crypto');
async function computeHash(arraybuffer) {
const hash = await crypto.subtle.digest({ name: 'SHA-512' }, arraybuffer);
return arrayBufferToBase64(hash);
}
function buildAvatarUpdater({ field }) {
return async (conversation, data, options = {}) => {
if (!conversation) {