Restrict message attachments shown in gallery & lightbox

This commit is contained in:
trevor-signal
2025-07-01 13:14:28 -04:00
committed by GitHub
parent bcb1a614ea
commit 708a1bb51f
2 changed files with 11 additions and 2 deletions

View File

@@ -3498,12 +3498,12 @@ function getAdjacentMessagesByConversation(
}
${
requireVisualMediaAttachments
? sqlFragment`hasVisualMediaAttachments IS 1 AND`
? sqlFragment`hasVisualMediaAttachments IS 1 AND isViewOnce IS 0 AND`
: sqlFragment``
}
${
requireFileAttachments
? sqlFragment`hasFileAttachments IS 1 AND`
? sqlFragment`hasFileAttachments IS 1 AND isViewOnce IS 0 AND`
: sqlFragment``
}
isStory IS 0 AND

View File

@@ -34,6 +34,7 @@ import type { MediaItemType } from '../../types/MediaItem';
import type { StateType as RootStateType } from '../reducer';
import type { MessageAttributesType } from '../../model-types';
import { MessageModel } from '../../models/messages';
import { isTapToView } from '../selectors/message';
const log = createLogger('mediaGallery');
@@ -150,6 +151,11 @@ function _cleanVisualAttachments(
.flatMap(message => {
let index = 0;
// Also checked via the DB query
if (isTapToView(message.attributes)) {
return [];
}
return (message.get('attachments') || []).map(
(attachment: AttachmentType): MediaType | undefined => {
if (
@@ -188,6 +194,9 @@ function _cleanFileAttachments(
): ReadonlyArray<MediaItemType> {
return rawDocuments
.map(message => {
if (isTapToView(message.attributes)) {
return;
}
const attachments = message.get('attachments') || [];
const attachment = attachments[0];
if (!attachment) {