providerLabel: consolidate provider-brand host matching #69

Closed
opened 2026-07-01 21:18:19 +00:00 by JMR-dev · 0 comments
JMR-dev commented 2026-07-01 21:18:19 +00:00 (Migrated from github.com)

Origin: code review of PR #54. Cosmetic — the suffix only renders when two labels already collide, and uniqueness is guaranteed regardless.

Problem

providerLabel()'s brand matching (FolderLabels.kt:13-19) is both over- and under-inclusive, and re-encodes host knowledge kept elsewhere:

  • Under-match: MailProvider.forImapHost is exact-match, so a manually configured Gmail account on the legacy host imap.googlemail.com misses imap.gmail.com and falls to the email-domain fallback — rendering "Drafts - gmail.com" instead of "Drafts - Gmail".
  • Over-match: contains("outlook") / contains("office365") brands any host containing those substrings as Outlook (contrived, but nothing prevents it).
  • Redundant disjunct: authType == AuthType.OAUTH_OUTLOOK can never independently fire today — Account.outlook() is the sole OAUTH_OUTLOOK constructor and hardcodes outlook.office365.com, which the substring already matches. (It is, however, the robust check of the three — keep it if consolidating.)

Host→brand knowledge now lives in both Account.outlook() and these UI substrings.

Suggested fix

Give MailProvider entries host aliases (or a matches(host) predicate) plus an Outlook brand entry, and resolve the label through the enum — one edit per provider instead of a growing when-branch in a UI file. Note MailProvider is documented as the app-password preset list that deliberately excludes Outlook, so this needs a small restructuring decision (brand table vs preset table) rather than a drop-in change.

Origin: code review of PR #54. Cosmetic — the suffix only renders when two labels already collide, and uniqueness is guaranteed regardless. ## Problem `providerLabel()`'s brand matching (`FolderLabels.kt:13-19`) is both over- and under-inclusive, and re-encodes host knowledge kept elsewhere: - **Under-match:** `MailProvider.forImapHost` is exact-match, so a manually configured Gmail account on the legacy host `imap.googlemail.com` misses `imap.gmail.com` and falls to the email-domain fallback — rendering "Drafts - gmail.com" instead of "Drafts - Gmail". - **Over-match:** `contains("outlook") / contains("office365")` brands any host containing those substrings as Outlook (contrived, but nothing prevents it). - **Redundant disjunct:** `authType == AuthType.OAUTH_OUTLOOK` can never independently fire today — `Account.outlook()` is the sole OAUTH_OUTLOOK constructor and hardcodes `outlook.office365.com`, which the substring already matches. (It is, however, the robust check of the three — keep it if consolidating.) Host→brand knowledge now lives in both `Account.outlook()` and these UI substrings. ## Suggested fix Give `MailProvider` entries host aliases (or a `matches(host)` predicate) plus an Outlook brand entry, and resolve the label through the enum — one edit per provider instead of a growing when-branch in a UI file. Note `MailProvider` is documented as the app-password preset list that deliberately excludes Outlook, so this needs a small restructuring decision (brand table vs preset table) rather than a drop-in change.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: JMR-dev/LibreMail#69