# Chat messages appearing in wrong order

**URL:** <https://meta.discourse.org/t/chat-messages-appearing-in-wrong-order/316619>\
**Category:** Bug\
**Tags:** chat\
**Created:** [July 16, 2024, 5:51pm UTC](https://meta.discourse.org/t/chat-messages-appearing-in-wrong-order/316619 "2024-07-16T17:51:34Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![davidb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/davidb/32/554671_2.png) [@davidb](https://meta.discourse.org/u/davidb)\
**Post date:** [July 22, 2024, 11:04am UTC](https://meta.discourse.org/t/chat-messages-appearing-in-wrong-order/316619/11 "2024-07-22T11:04:33Z")

</div>

This code might be useful to see how `MessageDestroyer` is used for deleting direct messages after the chat retention days:

> <https://github.com/discourse/discourse/blob/main/plugins/chat/app/jobs/scheduled/chat/delete_old_messages.rb#L27-L35>

In theory you could select any message with an `id` less than a certain number and pass those in to be destroyed (see [destroy\_in\_batches](https://github.com/discourse/discourse/blob/main/plugins/chat/app/services/chat/message_destroyer.rb#L5) method).

---

_[View the full topic](https://meta.discourse.org/t/chat-messages-appearing-in-wrong-order/316619)._
