Filter incoming bodyRanges, also filter before display

This commit is contained in:
Scott Nonnenberg 2023-04-11 17:16:46 -07:00 committed by GitHub
parent ec1246f60a
commit 4c9baaef80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 84 additions and 126 deletions

View file

@ -53,7 +53,7 @@ import * as expirationTimer from '../util/expirationTimer';
import { getUserLanguages } from '../util/userLanguages';
import type { ReactionType } from '../types/Reactions';
import { isValidUuid, UUID, UUIDKind } from '../types/UUID';
import { UUID, UUIDKind } from '../types/UUID';
import * as reactionUtil from '../reactions/util';
import * as Stickers from '../types/Stickers';
import * as Errors from '../types/errors';
@ -1957,30 +1957,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
id,
attachments: quote.attachments.slice(),
bodyRanges: quote.bodyRanges
.map(({ start, length, mentionUuid }) => {
strictAssert(
start != null,
'Received quote with a bodyRange.start == null'
);
strictAssert(
length != null,
'Received quote with a bodyRange.length == null'
);
if (!isValidUuid(mentionUuid)) {
log.warn(
`copyFromQuotedMessage: invalid mentionUuid ${mentionUuid}`
);
return undefined;
}
return {
start,
length,
mentionUuid,
};
})
.filter(isNotNil),
bodyRanges: quote.bodyRanges?.slice(),
// Just placeholder values for the fields
referencedMessageNotFound: false,