Move receipt queues into conversation queue to handle 428s

This commit is contained in:
Jamie Kyle 2023-02-06 09:24:34 -08:00 committed by GitHub
parent 3776a04c0b
commit 2bbcc4676e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 981 additions and 223 deletions

View file

@ -103,7 +103,6 @@ import {
isGroupV2,
} from '../../util/whatTypeOfConversation';
import { missingCaseError } from '../../util/missingCaseError';
import { viewedReceiptsJobQueue } from '../../jobs/viewedReceiptsJobQueue';
import { viewSyncJobQueue } from '../../jobs/viewSyncJobQueue';
import { ReadStatus } from '../../messages/MessageReadStatus';
import { isIncoming, isOutgoing } from '../selectors/message';
@ -147,6 +146,7 @@ import {
setQuoteByMessageId,
resetComposer,
} from './composer';
import { ReceiptType } from '../../types/Receipt';
// State
@ -1675,17 +1675,24 @@ export const markViewed = (messageId: string): void => {
if (isIncoming(message.attributes)) {
const convoAttributes = message.getConversation()?.attributes;
const conversationId = message.get('conversationId');
drop(
viewedReceiptsJobQueue.add({
viewedReceipt: {
messageId,
senderE164,
senderUuid,
timestamp,
isDirectConversation: convoAttributes
? isDirectConversation(convoAttributes)
: true,
},
conversationJobQueue.add({
type: conversationQueueJobEnum.enum.Receipts,
conversationId,
receiptsType: ReceiptType.Viewed,
receipts: [
{
messageId,
conversationId,
senderE164,
senderUuid,
timestamp,
isDirectConversation: convoAttributes
? isDirectConversation(convoAttributes)
: true,
},
],
})
);
}

View file

@ -55,11 +55,15 @@ import type { BoundActionCreatorsMapObject } from '../../hooks/useBoundActions';
import { useBoundActions } from '../../hooks/useBoundActions';
import { verifyStoryListMembers as doVerifyStoryListMembers } from '../../util/verifyStoryListMembers';
import { viewSyncJobQueue } from '../../jobs/viewSyncJobQueue';
import { viewedReceiptsJobQueue } from '../../jobs/viewedReceiptsJobQueue';
import { getOwn } from '../../util/getOwn';
import { SHOW_TOAST } from './toast';
import { ToastType } from '../../types/Toast';
import type { ShowToastActionType } from './toast';
import {
conversationJobQueue,
conversationQueueJobEnum,
} from '../../jobs/conversationJobQueue';
import { ReceiptType } from '../../types/Receipt';
export type StoryDataType = ReadonlyDeep<
{
@ -399,8 +403,11 @@ function markStoryRead(
ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(),
});
const conversationId = message.get('conversationId');
const viewedReceipt = {
messageId,
conversationId,
senderE164: message.attributes.source,
senderUuid: message.attributes.sourceUuid,
timestamp: message.attributes.sent_at,
@ -413,7 +420,14 @@ function markStoryRead(
}
if (window.Events.getStoryViewReceiptsEnabled()) {
drop(viewedReceiptsJobQueue.add({ viewedReceipt }));
drop(
conversationJobQueue.add({
type: conversationQueueJobEnum.enum.Receipts,
conversationId,
receiptsType: ReceiptType.Viewed,
receipts: [viewedReceipt],
})
);
}
await dataInterface.addNewStoryRead({