onSentMessage: Create destination conversation before further processing
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
This commit is contained in:
parent
a8ec995173
commit
db623d13b2
5 changed files with 184 additions and 29 deletions
|
@ -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");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue