mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 12:19:41 +00:00
Allow stage and send of video, even if we can't get screenshot
This commit is contained in:
41
ts/util/resolveDraftAttachmentOnDisk.ts
Normal file
41
ts/util/resolveDraftAttachmentOnDisk.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
// 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';
|
||||
|
||||
export function resolveDraftAttachmentOnDisk(
|
||||
attachment: AttachmentDraftType
|
||||
): AttachmentDraftType {
|
||||
let url = '';
|
||||
if (attachment.pending) {
|
||||
return attachment;
|
||||
}
|
||||
|
||||
if (attachment.screenshotPath) {
|
||||
url = window.Signal.Migrations.getAbsoluteDraftPath(
|
||||
attachment.screenshotPath
|
||||
);
|
||||
} else if (!isVideoAttachment(attachment) && attachment.path) {
|
||||
url = window.Signal.Migrations.getAbsoluteDraftPath(attachment.path);
|
||||
} else {
|
||||
log.warn(
|
||||
'resolveOnDiskAttachment: Attachment was missing both screenshotPath and path fields'
|
||||
);
|
||||
}
|
||||
return {
|
||||
...pick(attachment, [
|
||||
'blurHash',
|
||||
'caption',
|
||||
'contentType',
|
||||
'fileName',
|
||||
'path',
|
||||
'size',
|
||||
]),
|
||||
pending: false,
|
||||
url,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user