Chat messages appearing in wrong order

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

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 method).