onSentMessage: Create destination conversation before further processing

Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
This commit is contained in:
Scott Nonnenberg 2024-03-06 10:10:44 -08:00 committed by GitHub
parent a8ec995173
commit db623d13b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 184 additions and 29 deletions

View file

@ -8,6 +8,9 @@ import path from 'path';
import { compose } from 'lodash/fp';
import { escapeRegExp, isString, isRegExp } from 'lodash';
import type { ExtendedStorageID } from '../types/StorageService.d';
import type { ConversationModel } from '../models/conversations';
export const APP_ROOT_PATH = path.join(__dirname, '..', '..');
const PHONE_NUMBER_PATTERN = /\+\d{7,12}(\d{3})/g;
@ -23,6 +26,22 @@ const REDACTION_PLACEHOLDER = '[REDACTED]';
export type RedactFunction = (value: string) => string;
export function redactStorageID(
storageID: string,
version?: number,
conversation?: ConversationModel
): string {
const convoId = conversation ? ` ${conversation?.idForLogging()}` : '';
return `${version ?? '?'}:${storageID.substring(0, 3)}${convoId}`;
}
export function redactExtendedStorageID({
storageID,
storageVersion,
}: ExtendedStorageID): string {
return redactStorageID(storageID, storageVersion);
}
export const _redactPath = (filePath: string): RedactFunction => {
if (!isString(filePath)) {
throw new TypeError("'filePath' must be a string");