[Bug]: Webmail "Move to spam" only adds a SPAM keyword, never moves the message to Junk
Existing issue
- I have searched the existing issues and found no duplicate.
Problem description
In webmail, Move to spam doesn't move the message. It disappears, then comes back in the inbox on the next refresh, and the Junk folder stays empty.
The client sends Gmail-style labels (addLabels: ["SPAM"], removeLabels: ["INBOX"]), but modifyLabels in apps/email/server/src/lib/imap-driver.ts stores them as IMAP flags instead of moving the message:
await client.messageFlagsAdd(found, input.addLabels, { uid: true }); // adds keyword "SPAM"
await client.messageFlagsRemove(found, input.removeLabels, { uid: true }); // "INBOX" flag: no-opThe message stays in INBOX with a literal SPAM keyword, and the API returns ok: true.
The same path affects Archive and Move to inbox. Delete works because deleteThreads really moves the message.
Expected: System labels map to mailbox moves (SPAM → Junk, TRASH → Trash, removing INBOX → Archive), and only other labels are stored as flags.
Steps to reproduce
- Open webmail and select a message in the inbox.
- Choose Move to spam.
- Refresh. The message is back in the inbox, and Spam is empty.
- On the mail server:
doveadm fetch -u <user> flags mailbox INBOX KEYWORD SPAMshows the message with\Seen SPAM.
Environment
- OpenShip version/commit: openship-webmail v0.8.0 (
234d8a9), openship-mail 0.7.2;modifyLabelsis unchanged onmain - Deployment method: Docker (self-hosted)
- Operating system: Linux
- Browser (if applicable): any
Additional context
Archive is auto = no in the Dovecot config, so an archive move needs to create the mailbox if it doesn't exist.
Source: oblien/openship