New attachment storage system
This commit is contained in:
parent
273e1ccb15
commit
28664a606f
161 changed files with 2418 additions and 1562 deletions
|
@ -1,11 +1,13 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { pick } from 'lodash';
|
||||
|
||||
import * as log from '../logging/log';
|
||||
import type { AttachmentDraftType } from '../types/Attachment';
|
||||
import { isVideoAttachment } from '../types/Attachment';
|
||||
import {
|
||||
getLocalAttachmentUrl,
|
||||
AttachmentDisposition,
|
||||
} from './getLocalAttachmentUrl';
|
||||
|
||||
export function resolveDraftAttachmentOnDisk(
|
||||
attachment: AttachmentDraftType
|
||||
|
@ -16,29 +18,52 @@ export function resolveDraftAttachmentOnDisk(
|
|||
}
|
||||
|
||||
if (attachment.screenshotPath) {
|
||||
// Legacy
|
||||
url = window.Signal.Migrations.getAbsoluteDraftPath(
|
||||
attachment.screenshotPath
|
||||
);
|
||||
} else if (attachment.screenshot?.path) {
|
||||
url = getLocalAttachmentUrl(attachment.screenshot, {
|
||||
disposition: AttachmentDisposition.Draft,
|
||||
});
|
||||
} else if (!isVideoAttachment(attachment) && attachment.path) {
|
||||
url = window.Signal.Migrations.getAbsoluteDraftPath(attachment.path);
|
||||
url = getLocalAttachmentUrl(attachment, {
|
||||
disposition: AttachmentDisposition.Draft,
|
||||
});
|
||||
} else {
|
||||
log.warn(
|
||||
'resolveOnDiskAttachment: Attachment was missing both screenshotPath and path fields'
|
||||
);
|
||||
}
|
||||
|
||||
const {
|
||||
blurHash,
|
||||
caption,
|
||||
clientUuid,
|
||||
contentType,
|
||||
fileName,
|
||||
flags,
|
||||
path,
|
||||
size,
|
||||
width,
|
||||
height,
|
||||
version,
|
||||
localKey,
|
||||
} = attachment;
|
||||
|
||||
return {
|
||||
...pick(attachment, [
|
||||
'blurHash',
|
||||
'caption',
|
||||
'clientUuid',
|
||||
'contentType',
|
||||
'fileName',
|
||||
'flags',
|
||||
'path',
|
||||
'size',
|
||||
'width',
|
||||
'height',
|
||||
]),
|
||||
blurHash,
|
||||
caption,
|
||||
clientUuid,
|
||||
contentType,
|
||||
fileName,
|
||||
flags,
|
||||
path,
|
||||
size,
|
||||
width,
|
||||
height,
|
||||
version,
|
||||
localKey,
|
||||
pending: false,
|
||||
url,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue