fix: include mailboxPath in IMAP email ID to prevent UID collisions #511
@@ -296,8 +296,7 @@ void main() {
|
||||
expect(archiveEmail, isNotNull);
|
||||
expect(archiveEmail!.mailboxPath, 'Archive');
|
||||
|
||||
final inboxEmails =
|
||||
await r.emails.observeEmails('acc-1', 'INBOX').first;
|
||||
final inboxEmails = await r.emails.observeEmails('acc-1', 'INBOX').first;
|
||||
expect(inboxEmails, hasLength(1));
|
||||
expect(inboxEmails.first.id, 'acc-1:INBOX:50');
|
||||
|
||||
|
||||
@@ -536,16 +536,16 @@ void main() {
|
||||
// Two emails with the same UID but in different mailboxes — old format.
|
||||
final now = DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
||||
rawDb.execute(
|
||||
"INSERT INTO emails (id, account_id, mailbox_path, uid, received_at, thread_id) "
|
||||
'INSERT INTO emails (id, account_id, mailbox_path, uid, received_at, thread_id) '
|
||||
"VALUES ('acc-1:50', 'acc-1', 'INBOX', 50, $now, 'acc-1:50')",
|
||||
);
|
||||
rawDb.execute(
|
||||
"INSERT INTO emails (id, account_id, mailbox_path, uid, received_at) "
|
||||
'INSERT INTO emails (id, account_id, mailbox_path, uid, received_at) '
|
||||
"VALUES ('acc-1:50-arch', 'acc-1', 'Archive', 50, $now)",
|
||||
);
|
||||
// A third email with a Message-ID-based thread_id (should not be changed).
|
||||
rawDb.execute(
|
||||
"INSERT INTO emails (id, account_id, mailbox_path, uid, received_at, thread_id) "
|
||||
'INSERT INTO emails (id, account_id, mailbox_path, uid, received_at, thread_id) '
|
||||
"VALUES ('acc-1:99', 'acc-1', 'INBOX', 99, $now, '<original@example.com>')",
|
||||
);
|
||||
|
||||
@@ -556,13 +556,13 @@ void main() {
|
||||
|
||||
// Thread for the first email (old-format IDs).
|
||||
rawDb.execute(
|
||||
"INSERT INTO threads (account_id, mailbox_path, id, latest_date, latest_email_id, email_ids_json) "
|
||||
'INSERT INTO threads (account_id, mailbox_path, id, latest_date, latest_email_id, email_ids_json) '
|
||||
"VALUES ('acc-1', 'INBOX', 'acc-1:50', $now, 'acc-1:50', '[\"acc-1:50\"]')",
|
||||
);
|
||||
|
||||
// A pending change referencing the first email's old ID.
|
||||
rawDb.execute(
|
||||
"INSERT INTO pending_changes (account_id, resource_type, resource_id, change_type, payload, created_at) "
|
||||
'INSERT INTO pending_changes (account_id, resource_type, resource_id, change_type, payload, created_at) '
|
||||
"VALUES ('acc-1', 'Email', 'acc-1:50', 'flag_seen', '{\"seen\":true}', $now)",
|
||||
);
|
||||
|
||||
@@ -589,8 +589,7 @@ void main() {
|
||||
expect(bodyRows.first.emailId, 'acc-1:INBOX:50');
|
||||
|
||||
// thread_id where it was the email's own ID should be updated.
|
||||
final inboxEmail =
|
||||
emailRows.firstWhere((r) => r.id == 'acc-1:INBOX:50');
|
||||
final inboxEmail = emailRows.firstWhere((r) => r.id == 'acc-1:INBOX:50');
|
||||
expect(inboxEmail.threadId, 'acc-1:INBOX:50');
|
||||
|
||||
// thread_id based on a real Message-ID must be left unchanged.
|
||||
|
||||
Reference in New Issue
Block a user