New attachment storage system

This commit is contained in:
Fedor Indutny
2024-07-11 12:44:09 -07:00
committed by GitHub
parent 273e1ccb15
commit 28664a606f
161 changed files with 2418 additions and 1562 deletions
+7 -5
View File
@@ -14,12 +14,14 @@ import {
import type {
AttachmentType,
AttachmentWithHydratedData,
LocalAttachmentV2Type,
UploadedAttachmentType,
} from './Attachment';
import { toLogFormat } from './errors';
import type { LoggerType } from './Logging';
import type { ServiceIdString } from './ServiceId';
import type { migrateDataToFileSystem } from '../util/attachments/migrateDataToFilesystem';
import { getLocalAttachmentUrl } from '../util/getLocalAttachmentUrl';
type GenericEmbeddedContactType<AvatarType> = {
name?: Name;
@@ -150,11 +152,9 @@ export function embeddedContactSelector(
regionCode?: string;
firstNumber?: string;
serviceId?: ServiceIdString;
getAbsoluteAttachmentPath: (path: string) => string;
}
): EmbeddedContactType {
const { getAbsoluteAttachmentPath, firstNumber, serviceId, regionCode } =
options;
const { firstNumber, serviceId, regionCode } = options;
let { avatar } = contact;
if (avatar && avatar.avatar) {
@@ -166,7 +166,7 @@ export function embeddedContactSelector(
avatar: {
...avatar.avatar,
path: avatar.avatar.path
? getAbsoluteAttachmentPath(avatar.avatar.path)
? getLocalAttachmentUrl(avatar.avatar)
: undefined,
},
};
@@ -209,7 +209,9 @@ export function parseAndWriteAvatar(
message: MessageAttributesType;
getRegionCode: () => string | undefined;
logger: LoggerType;
writeNewAttachmentData: (data: Uint8Array) => Promise<string>;
writeNewAttachmentData: (
data: Uint8Array
) => Promise<LocalAttachmentV2Type>;
}
): Promise<EmbeddedContactType> => {
const { message, getRegionCode, logger } = context;