From 4db2ae5753f79ed369cd70f54ae75f6b3e01006b Mon Sep 17 00:00:00 2001 From: Devin Binnie <52460000+devinbinnie@users.noreply.github.com> Date: Wed, 1 May 2024 10:44:09 -0400 Subject: [PATCH] [MM-58070] Ensure the batched post handler also send websocket acknowledgements (#26938) * [MM-58070] Ensure the batched post handler also send websocket acknowledgements * Add ack for missing root post error --------- Co-authored-by: Mattermost Build --- webapp/channels/src/actions/new_post.ts | 3 +++ webapp/channels/src/actions/websocket_actions.jsx | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/webapp/channels/src/actions/new_post.ts b/webapp/channels/src/actions/new_post.ts index 4b2d31c92a..68dc631261 100644 --- a/webapp/channels/src/actions/new_post.ts +++ b/webapp/channels/src/actions/new_post.ts @@ -49,6 +49,9 @@ export function completePostReceive(post: Post, websocketMessageProps: NewPostMe const result = await dispatch(PostActions.getPostThread(post.root_id)); if ('error' in result) { + if (websocketMessageProps.should_ack) { + WebSocketClient.acknowledgePostedNotification(post.id, 'error', 'missing_root_post', result.error); + } return {error: result.error}; } } diff --git a/webapp/channels/src/actions/websocket_actions.jsx b/webapp/channels/src/actions/websocket_actions.jsx index 877c8bbad0..8184cf178b 100644 --- a/webapp/channels/src/actions/websocket_actions.jsx +++ b/webapp/channels/src/actions/websocket_actions.jsx @@ -733,6 +733,12 @@ export function handleNewPostEvents(queue) { console.log('handleNewPostEvents - new posts received', posts); } + posts.forEach((post, index) => { + if (queue[index].data.should_ack) { + WebSocketClient.acknowledgePostedNotification(post.id, 'not_sent', 'too_many_posts'); + } + }); + // Receive the posts as one continuous block since they were received within a short period const crtEnabled = isCollapsedThreadsEnabled(myGetState()); const actions = posts.map((post) => receivedNewPost(post, crtEnabled));