filterValidAttachments: Allow attachments with no thumbnail
Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
parent
6a52ad2e94
commit
f71183119f
4 changed files with 8 additions and 29 deletions
|
@ -38,8 +38,9 @@ export type DeleteForMeAttributesType = {
|
||||||
const deletes = new Map<string, DeleteForMeAttributesType>();
|
const deletes = new Map<string, DeleteForMeAttributesType>();
|
||||||
|
|
||||||
async function remove(item: DeleteForMeAttributesType): Promise<void> {
|
async function remove(item: DeleteForMeAttributesType): Promise<void> {
|
||||||
await removeSyncTaskById(item.syncTaskId);
|
const { syncTaskId } = item;
|
||||||
deletes.delete(item.envelopeId);
|
await removeSyncTaskById(syncTaskId);
|
||||||
|
deletes.delete(syncTaskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function forMessage(
|
export async function forMessage(
|
||||||
|
@ -84,7 +85,7 @@ export async function onDelete(item: DeleteForMeAttributesType): Promise<void> {
|
||||||
|
|
||||||
const logId = `DeletesForMe.onDelete(sentAt=${message.sentAt},timestamp=${item.timestamp},envelopeId=${item.envelopeId})`;
|
const logId = `DeletesForMe.onDelete(sentAt=${message.sentAt},timestamp=${item.timestamp},envelopeId=${item.envelopeId})`;
|
||||||
|
|
||||||
deletes.set(item.envelopeId, item);
|
deletes.set(item.syncTaskId, item);
|
||||||
|
|
||||||
if (!conversation) {
|
if (!conversation) {
|
||||||
log.warn(`${logId}: Conversation not found!`);
|
log.warn(`${logId}: Conversation not found!`);
|
||||||
|
|
|
@ -40,7 +40,9 @@ export type ViewSyncAttributesType = {
|
||||||
const viewSyncs = new Map<string, ViewSyncAttributesType>();
|
const viewSyncs = new Map<string, ViewSyncAttributesType>();
|
||||||
|
|
||||||
async function remove(sync: ViewSyncAttributesType): Promise<void> {
|
async function remove(sync: ViewSyncAttributesType): Promise<void> {
|
||||||
await DataWriter.removeSyncTaskById(sync.syncTaskId);
|
const { syncTaskId } = sync;
|
||||||
|
viewSyncs.delete(syncTaskId);
|
||||||
|
await DataWriter.removeSyncTaskById(syncTaskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function forMessage(
|
export async function forMessage(
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
// Copyright 2016 Signal Messenger, LLC
|
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
|
|
||||||
import type { MessageReceiptType } from './MessageReceipts';
|
|
||||||
|
|
||||||
// This function is necessary because the only thing we can guarantee will be unique is
|
|
||||||
// three pieces of data: sender, deviceId, and timestamp.
|
|
||||||
// Because we don't care which device interacted with our message, we collapse this down
|
|
||||||
// to: sender + timestamp.
|
|
||||||
// In some cases, modifiers are stored in the same map, so we also add the modifier type
|
|
||||||
|
|
||||||
type ModifierType = MessageReceiptType | 'readsync' | 'viewsync';
|
|
||||||
|
|
||||||
export function generateCacheKey({
|
|
||||||
sender,
|
|
||||||
timestamp,
|
|
||||||
type,
|
|
||||||
}: {
|
|
||||||
sender: string;
|
|
||||||
timestamp: number;
|
|
||||||
type: ModifierType;
|
|
||||||
}): string {
|
|
||||||
return `cacheKey-${sender}-${timestamp}-${type}`;
|
|
||||||
}
|
|
|
@ -232,7 +232,7 @@ function filterValidAttachments(
|
||||||
attributes: ReadonlyMessageAttributesType
|
attributes: ReadonlyMessageAttributesType
|
||||||
): Array<AttachmentType> {
|
): Array<AttachmentType> {
|
||||||
return (attributes.attachments ?? []).filter(
|
return (attributes.attachments ?? []).filter(
|
||||||
item => item.thumbnail && !item.pending && !item.error
|
item => !item.pending && !item.error
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue