Skip to content

fix(ui): show "Mark not spam" for unflagged junk messages - #14324

Merged
ChristophWurst merged 1 commit into
mainfrom
fix/junk-folder-not-spam-action
Nov 26, 2026
Merged

ChristophWurst merged 1 commit into
mainfrom
fix/junk-folder-not-spam-action

Conversation

@ChristophWurst

Copy link
Copy Markdown
Member

Context

Fixes #11168

Messages in the Junk folder usually have no $junk keyword. The UI offered "Mark as spam" for them, which only set the keyword and left the message in the folder, so users had to click again to get "Mark not spam".

Approach

The junk state is now read in one place, the store method isEnvelopeJunk. A message counts as junk if it has $junk, or if it is in a junk folder (the account's junk folder or a folder with the junk special use) and has no $notjunk. The row and thread menus, the junk icons, the bulk selection and the toggle and move actions all use it. Outside junk folders nothing changes.

Visible effects:

  • every unflagged message in the Junk folder now shows the junk icon, and clicking the icon moves the message to the inbox;
  • those messages show "Mark not spam";
  • the "Mark as spam" quick action stays one-way: it skips messages that are already junk and never moves them back to the inbox.

Known limit: a message that keeps $notjunk inside the Junk folder (for example a nonjunk keyword set by another client, or a message moved back by hand) still shows "Mark as spam".

The $Junk and $NotJunk keyword names are unchanged, so #13815 would only need to touch this method.

Screenshots

Before After
Before: row menu After: row menu
Before: thread view After: thread view

Testing

Unit tests cover the junk method, the move and toggle decisions (including the restore after a failed request), the quick action in both layouts, the menu and icon properties, and the bulk selection methods.

Checked by hand in a browser against a local IMAP account with a Junk folder: the row menu, icon and thread view, the bulk menu label, the quick action on a single message and on a thread, and "Mark not spam" moving a message to the inbox. Not tested: JMAP accounts, the dark theme, the mobile layout, and the spam and ham reports sent to the learning backend.

Assisted by ClaudeCode:claude-sonnet-5-5, ClaudeCode:claude-opus-5-5, ClaudeCode:claude-haiku-5-5

Messages delivered to the Junk folder usually have no $junk keyword.
The UI offered "Mark as spam" for them and only set $junk, so the
message stayed in the folder and users had to click again to get
"Mark not spam".

Junk state is now derived in one store method, isEnvelopeJunk: $junk
always counts, and an unflagged message in a junk folder (the account's
junk mailbox or a folder with the junk special use) counts as junk
unless it has $notjunk. The row and thread menus, the junk icons, the
bulk selection, and the toggle and move actions use it.

The "Mark as spam" quick action stays one-way: it skips messages that
are already junk and never moves a message back to the inbox. The
normal menu toggle still works in both directions.

Not changed: the $Junk/$NotJunk keyword names (#13815), the order of
the flag updates in setFlags, and the $notjunk flag on the copy that
MoveJunkListener creates in INBOX. A message that keeps $notjunk
inside the Junk folder still shows "Mark as spam".

Fixes #11168

Assisted-by: ClaudeCode:claude-sonnet-5-5
Assisted-by: ClaudeCode:claude-opus-5-5
Assisted-by: ClaudeCode:claude-haiku-5-5
Signed-off-by: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com>
@ChristophWurst

Copy link
Copy Markdown
Member Author

/backport to stable5.13

Assisted by ClaudeCode:claude-sonnet-5-5

@nextcloud-command nextcloud-command added the AI assisted This PR contains AI-assisted commits label Nov 26, 2026
@ChristophWurst
ChristophWurst merged commit a563b8d into main Nov 26, 2026
37 checks passed
@ChristophWurst
ChristophWurst deleted the fix/junk-folder-not-spam-action branch November 26, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review AI assisted This PR contains AI-assisted commits bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Emails in junk folder not marked as spam

3 participants