MAM: “after” is broken because it relies on the id_ ordering
If, for some reason, the id_ field of the history does not represent the actual chronological ordering (if you imported old archives, for examples), then any request containing a “after” field will return wrong results.
We should stop relying on the id_ ordering, and instead use only the date_ column. However, we currently only store INTEGERs, and that’s not precise (only to the second) enough for proper ordering if messages are received in a short interval.
I could convert the INTEGER dates into proper datetime (postgresql) or real (sqlite) which have a very high precision (like milliseconds), and use only that to order archives.
What do you think?