In order to minimize the amount of storage space that the Chat module's data consumes, it incorporates a set of scheduled tasks, which delete old and inactive records on a regular basis.
This scheduled task deletes chat messages, rooms and anonymous users which haven't logged any activity for the amount of time specified in settings. The age of the data that is to be deleted can be specified in Settings -> Community -> Chat -> Days of inactivity needed to delete chat records.
The order of performed deleting operations is as follows:
1.Delete messages - messages that were sent earlier than the specified amount of time.
2.Delete rooms - rooms that meet all of the following criteria will be deleted:
b.contains no messages
c.was created earlier than the specified amount of time
d.doesn't contain any registered (non-anonymous) user that has elevated room permissions
e.doesn't contain any anonymous user that has been on-line in the room during specified amount of time
3.Delete users - users meeting all of the following conditions will be deleted:
a.haven't sent any message in the specified amount of time
b.haven't been on-line in the specified amount of time
This scheduled task removes anonymous users who stopped sending pings to the server without going off-line (e.g. their connection was interrupted or they simply closed the browser window).
When you delete a room, it becomes disabled and scheduled to be deleted instead of being physically deleted from the database right away.
This scheduled task is by default executed once a day to delete the rooms marked for deletion.
This behavior ensures that users present in such room have a chance to get notified about the fact that the room they are in is getting deleted.