Use correct timestamp for receipts of edited messages
This commit is contained in:
parent
8fe0047822
commit
5869717cd3
21 changed files with 156 additions and 52 deletions
|
@ -10,6 +10,7 @@ import * as log from '../logging/log';
|
|||
import * as Errors from '../types/errors';
|
||||
import { deleteForEveryone } from '../util/deleteForEveryone';
|
||||
import { drop } from '../util/drop';
|
||||
import { getMessageSentTimestampSet } from '../util/getMessageSentTimestampSet';
|
||||
|
||||
export type DeleteAttributesType = {
|
||||
targetSentTimestamp: number;
|
||||
|
@ -31,10 +32,11 @@ export class Deletes extends Collection<DeleteModel> {
|
|||
}
|
||||
|
||||
forMessage(message: MessageModel): Array<DeleteModel> {
|
||||
const sentTimestamps = getMessageSentTimestampSet(message.attributes);
|
||||
const matchingDeletes = this.filter(item => {
|
||||
return (
|
||||
item.get('targetSentTimestamp') === message.get('sent_at') &&
|
||||
item.get('fromId') === getContactId(message.attributes)
|
||||
item.get('fromId') === getContactId(message.attributes) &&
|
||||
sentTimestamps.has(item.get('targetSentTimestamp'))
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import { drop } from '../util/drop';
|
|||
import { filter, size } from '../util/iterables';
|
||||
import { getContactId } from '../messages/helpers';
|
||||
import { handleEditMessage } from '../util/handleEditMessage';
|
||||
import { getMessageSentTimestamp } from '../util/getMessageSentTimestamp';
|
||||
|
||||
export type EditAttributesType = {
|
||||
conversationId: string;
|
||||
|
@ -20,9 +21,10 @@ export type EditAttributesType = {
|
|||
const edits = new Set<EditAttributesType>();
|
||||
|
||||
export function forMessage(message: MessageModel): Array<EditAttributesType> {
|
||||
const sentAt = getMessageSentTimestamp(message.attributes, { log });
|
||||
const matchingEdits = filter(edits, item => {
|
||||
return (
|
||||
item.targetSentTimestamp === message.get('sent_at') &&
|
||||
item.targetSentTimestamp === sentAt &&
|
||||
item.fromId === getContactId(message.attributes)
|
||||
);
|
||||
});
|
||||
|
|
|
@ -24,6 +24,7 @@ import dataInterface from '../sql/Client';
|
|||
import * as log from '../logging/log';
|
||||
import { getSourceUuid } from '../messages/helpers';
|
||||
import { queueUpdateMessage } from '../util/messageBatcher';
|
||||
import { getMessageSentTimestamp } from '../util/getMessageSentTimestamp';
|
||||
|
||||
const { deleteSentProtoRecipient } = dataInterface;
|
||||
|
||||
|
@ -159,7 +160,7 @@ export class MessageReceipts extends Collection<MessageReceiptModel> {
|
|||
return [];
|
||||
}
|
||||
|
||||
const sentAt = message.get('sent_at');
|
||||
const sentAt = getMessageSentTimestamp(message.attributes, { log });
|
||||
const receipts = this.filter(
|
||||
receipt => receipt.get('messageSentAt') === sentAt
|
||||
);
|
||||
|
|
|
@ -16,6 +16,7 @@ import { getContactId, getContact } from '../messages/helpers';
|
|||
import { isDirectConversation, isMe } from '../util/whatTypeOfConversation';
|
||||
import { isOutgoing, isStory } from '../state/selectors/message';
|
||||
import { strictAssert } from '../util/assert';
|
||||
import { getMessageSentTimestampSet } from '../util/getMessageSentTimestampSet';
|
||||
|
||||
export class ReactionModel extends Model<ReactionAttributesType> {}
|
||||
|
||||
|
@ -31,9 +32,10 @@ export class Reactions extends Collection<ReactionModel> {
|
|||
}
|
||||
|
||||
forMessage(message: MessageModel): Array<ReactionModel> {
|
||||
const sentTimestamps = getMessageSentTimestampSet(message.attributes);
|
||||
if (isOutgoing(message.attributes)) {
|
||||
const outgoingReactions = this.filter(
|
||||
item => item.get('targetTimestamp') === message.get('sent_at')
|
||||
const outgoingReactions = this.filter(item =>
|
||||
sentTimestamps.has(item.get('targetTimestamp'))
|
||||
);
|
||||
|
||||
if (outgoingReactions.length > 0) {
|
||||
|
@ -44,14 +46,15 @@ export class Reactions extends Collection<ReactionModel> {
|
|||
}
|
||||
|
||||
const senderId = getContactId(message.attributes);
|
||||
const sentAt = message.get('sent_at');
|
||||
const reactionsBySource = this.filter(re => {
|
||||
const targetSender = window.ConversationController.lookupOrCreate({
|
||||
uuid: re.get('targetAuthorUuid'),
|
||||
reason: 'Reactions.forMessage',
|
||||
});
|
||||
const targetTimestamp = re.get('targetTimestamp');
|
||||
return targetSender?.id === senderId && targetTimestamp === sentAt;
|
||||
return (
|
||||
targetSender?.id === senderId && sentTimestamps.has(targetTimestamp)
|
||||
);
|
||||
});
|
||||
|
||||
if (reactionsBySource.length > 0) {
|
||||
|
|
|
@ -13,6 +13,7 @@ import * as log from '../logging/log';
|
|||
import * as Errors from '../types/errors';
|
||||
import { StartupQueue } from '../util/StartupQueue';
|
||||
import { queueUpdateMessage } from '../util/messageBatcher';
|
||||
import { getMessageSentTimestamp } from '../util/getMessageSentTimestamp';
|
||||
|
||||
export type ReadSyncAttributesType = {
|
||||
senderId: string;
|
||||
|
@ -66,10 +67,13 @@ export class ReadSyncs extends Collection {
|
|||
uuid: message.get('sourceUuid'),
|
||||
reason: 'ReadSyncs.forMessage',
|
||||
});
|
||||
const messageTimestamp = getMessageSentTimestamp(message.attributes, {
|
||||
log,
|
||||
});
|
||||
const sync = this.find(item => {
|
||||
return (
|
||||
item.get('senderId') === sender?.id &&
|
||||
item.get('timestamp') === message.get('sent_at')
|
||||
item.get('timestamp') === messageTimestamp
|
||||
);
|
||||
});
|
||||
if (sync) {
|
||||
|
|
|
@ -16,6 +16,7 @@ import { queueAttachmentDownloads } from '../util/queueAttachmentDownloads';
|
|||
import * as log from '../logging/log';
|
||||
import { GiftBadgeStates } from '../components/conversation/Message';
|
||||
import { queueUpdateMessage } from '../util/messageBatcher';
|
||||
import { getMessageSentTimestamp } from '../util/getMessageSentTimestamp';
|
||||
|
||||
export type ViewSyncAttributesType = {
|
||||
senderId: string;
|
||||
|
@ -44,17 +45,18 @@ export class ViewSyncs extends Collection {
|
|||
uuid: message.get('sourceUuid'),
|
||||
reason: 'ViewSyncs.forMessage',
|
||||
});
|
||||
const messageTimestamp = getMessageSentTimestamp(message.attributes, {
|
||||
log,
|
||||
});
|
||||
const syncs = this.filter(item => {
|
||||
return (
|
||||
item.get('senderId') === sender?.id &&
|
||||
item.get('timestamp') === message.get('sent_at')
|
||||
item.get('timestamp') === messageTimestamp
|
||||
);
|
||||
});
|
||||
if (syncs.length) {
|
||||
log.info(
|
||||
`Found ${syncs.length} early view sync(s) for message ${message.get(
|
||||
'sent_at'
|
||||
)}`
|
||||
`Found ${syncs.length} early view sync(s) for message ${messageTimestamp}`
|
||||
);
|
||||
this.remove(syncs);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue