Vandelay import->export caused emails to show in random order in roundcubemail

Issue Description

After an import->export using vandelay of few hundreds of emails, the order in which they got displayed in roundcubemail was not in descending time order but came all over the place. The latest emails actually got put on the last page at least in roundcubemail.

Expected Behavior

Email show latest email first, in descending date order.

Reproduction Steps

It wasn’t complicated, just a simple import and export

vandelay import --url "..." --auth-basic ... --account-name "[email protected]" --auth-password "...." --allow-invalid-certs "emails.sqlite"
vandelay export --url "..." --auth-basic ... --account-name "[email protected]" --auth-password "...." --allow-invalid-certs "emails.sqlite"

Stalwart Version

v0.16.x

Installation Method

Binary (Linux)

Database Backend

MySQL

Blob Storage

S3-compatible

Search Engine

MySQL

Directory Backend

SQL

Additional Context

They got sorted right in thunderbird at least. I did a full account maintenance, that didn’t to fix the issue either.

I ended up having to force roundcubemail to sort by date by adding this:
$config['message_sort_col'] = 'date';

But I don’t think that is ideal solution for people running roundcubemail in front of Stalwart.

I am running latest roundcubemail, version 1.7.4-1

I have reviewed the documentation and FAQ and confirm that my issue is NOT addressed there.

on

I have searched this support forum (open and closed topics) and confirm this is not a duplicate.

on

I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.

on

Roundcube’s default sort column is empty, meaning it lists messages in the order the server holds them, i.e. by IMAP UID. vandelay imported them in the order it read them from the source, not by date, so the UIDs on the new server aren’t chronological even though every date came across intact. Thunderbird sorts by date, hence the difference. Account maintenance can’t change it either: recalculating UIDs follows the same ingest order.

So message_sort_col is the correct setting here. 'arrival' works as well as 'date', since Stalwart supports server-side SORT, and users can also pick the sort column themselves in the list options. vandelay could export in received-date order so the UIDs come out chronological for the next person; that’s an easy change on its side.