mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-05-08 08:58:38 +01:00
Filter incoming bodyRanges, also filter before display
This commit is contained in:
@@ -85,7 +85,7 @@ import {
|
||||
} from '../Crypto';
|
||||
import * as Bytes from '../Bytes';
|
||||
import type { DraftBodyRangeMention } from '../types/BodyRange';
|
||||
import { BodyRange } from '../types/BodyRange';
|
||||
import { BodyRange, hydrateRanges } from '../types/BodyRange';
|
||||
import { migrateColor } from '../util/migrateColor';
|
||||
import { isNotNil } from '../util/isNotNil';
|
||||
import { dropNull } from '../util/dropNull';
|
||||
@@ -1094,24 +1094,7 @@ export class ConversationModel extends window.Backbone
|
||||
const draft = this.get('draft');
|
||||
|
||||
const rawBodyRanges = this.get('draftBodyRanges') || [];
|
||||
const bodyRanges = rawBodyRanges.map(range => {
|
||||
// Hydrate user information on mention
|
||||
if (BodyRange.isMention(range)) {
|
||||
const conversation = findAndFormatContact(range.mentionUuid);
|
||||
|
||||
return {
|
||||
...range,
|
||||
conversationID: conversation.id,
|
||||
replacementText: conversation.title,
|
||||
};
|
||||
}
|
||||
|
||||
if (BodyRange.isFormatting(range)) {
|
||||
return range;
|
||||
}
|
||||
|
||||
throw missingCaseError(range);
|
||||
});
|
||||
const bodyRanges = hydrateRanges(rawBodyRanges, findAndFormatContact);
|
||||
|
||||
if (draft) {
|
||||
return {
|
||||
@@ -3902,24 +3885,7 @@ export class ConversationModel extends window.Backbone
|
||||
}
|
||||
|
||||
const rawBodyRanges = this.get('lastMessageBodyRanges') || [];
|
||||
const bodyRanges = rawBodyRanges.map(range => {
|
||||
// Hydrate user information on mention
|
||||
if (BodyRange.isMention(range)) {
|
||||
const conversation = findAndFormatContact(range.mentionUuid);
|
||||
|
||||
return {
|
||||
...range,
|
||||
conversationID: conversation.id,
|
||||
replacementText: conversation.title,
|
||||
};
|
||||
}
|
||||
|
||||
if (BodyRange.isFormatting(range)) {
|
||||
return range;
|
||||
}
|
||||
|
||||
throw missingCaseError(range);
|
||||
});
|
||||
const bodyRanges = hydrateRanges(rawBodyRanges, findAndFormatContact);
|
||||
|
||||
const text = stripNewlinesForLeftPane(lastMessageText);
|
||||
const prefix = this.get('lastMessagePrefix');
|
||||
|
||||
+2
-25
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user