Skip to content

Commit

Permalink
[MM-58070] Ensure the batched post handler also send websocket acknow…
Browse files Browse the repository at this point in the history
…ledgements (#26938) (#26939)

* [MM-58070] Ensure the batched post handler also send websocket acknowledgements

* Add ack for missing root post error

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
(cherry picked from commit 4db2ae5)

Co-authored-by: Devin Binnie <52460000+devinbinnie@users.noreply.github.com>
  • Loading branch information
mattermost-build and devinbinnie committed May 1, 2024
1 parent 97978c8 commit 0150021
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions webapp/channels/src/actions/new_post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,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};
}
}
Expand Down
6 changes: 6 additions & 0 deletions webapp/channels/src/actions/websocket_actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 0150021

Please sign in to comment.