Skip to content

feat(account): generate PoliNetwork email signatures - #199

Draft
Diubii wants to merge 1 commit into
mainfrom
feat/email-signature
Draft

Diubii wants to merge 1 commit into
mainfrom
feat/email-signature

Conversation

@Diubii

@Diubii Diubii commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

What

A new page, Account › Email signature (/dashboard/account/signature), open to anyone with people:self. It generates a PoliNetwork signature to paste into a mail client.

  • Templates. There is one template per kind of role the person holds, so each person sees only theirs:

    • Carica: Presidente or Segretario, shown above the name.
    • Direttivo
    • Admin: Capo Admin with scope, Admin.
    • Team: Lead or member, with the team.
    • Socio
  • Data from the backend, read-only.

  • Customization from the template:

    • which roles to show
    • layout: Side, Stacked or Compact
    • language: Italiano or English
    • optionally pronouns, phone and LinkedIn (a link or a handle, normalized to linkedin.com/in/…)

    The PoliNetwork logo and blue are always there.

  • Output:

    • Copy signature puts rich HTML and plain text on the clipboard.
    • Download .htm is for Outlook and Thunderbird.
    • Copy HTML code and Copy plain text: the plain text is for the Gmail and Outlook phone apps.
    • The page has step-by-step instructions for Gmail, Outlook, Apple Mail, Thunderbird and the phone apps.
  • Preview in a sandboxed iframe, so the dashboard's CSS can't change how it looks. A Desktop/Phone toggle shows it at 360px.

  • Remembered choices. Template, layout, language and roles are kept in localStorage. Phone and LinkedIn are not, since they're personal data.

Email-safe HTML (src/features/signature/signature.ts)

Everything is in pure functions, unit-tested in tests/signature.test.mjs:

  • nested tables and inline styles only
  • no classes, <style>, div, flexbox, SVG, web fonts or data: URIs
  • Arial/Helvetica, with exact line heights plus mso-line-height-rule:exactly for Outlook
  • the logo is an HTTPS PNG with width/height attributes, from the SIGNATURE_LOGO_URL env, which defaults to the backend's email logo on GitHub (192px, which also covers retina)
  • inline items don't break internally, only between one another
  • whatever the user types is HTML-escaped

Compatibility with the backend

If me.roles isn't available yet (backend not released) or the snapshot is stale, the page offers only the templates from the People record and shows a warning. It never fails. In agent mode, the roles come from AGENT_ROLES (default direttivo,presidente,socio).

Other changes

  • Nav: Account › Email signature (nav.ts, matchPath).
  • MCP: operation people.me.signature (peopleSelfMiddleware).
  • tests/server-security.test.mjs lists the new functions file.
  • Docs: README (SIGNATURE_LOGO_URL, AGENT_ROLES), AGENTS.md, design.md (Editor template).

How I tested it

Dashboard page (agent mode, Chromium):

  • 1440px light and dark, and 390px mobile: no console errors. On mobile the choices come before the instructions.
  • Firefox: the page loads and Copy signature works without errors.

Clipboard (Chromium) – Copy signature, then a real Ctrl+V into a contenteditable editor, like the signature boxes in Gmail and Outlook web:

  • text/html and text/plain are both on the clipboard.
  • After pasting, the logo, the mailto:, tel:, LinkedIn and website links, and the styles are all intact.

Rendering – every template × layout at 640px and 360px:

  • in Chromium, the engine behind Gmail web, Outlook web and new Outlook (WebView2)
  • in Firefox, the engine behind Thunderbird
  • no broken images and no horizontal overflow

Forced dark mode (Blink forceDarkModeEnabled, which approximates the Gmail and Outlook apps' inversion): the signature stays readable and the logo holds up.

Validation: an invalid phone blocks the copy, focuses the field and sets aria-invalid.

Checks: pnpm check has 0 errors (the 46 warnings were already on main), and pnpm typecheck, pnpm test (266/266) and pnpm build pass.

Not tested, to check by hand

  • Classic Outlook for Windows (Word engine): the markup follows its constraints, but I couldn't run it.
  • Apple Mail (macOS) and Mail on iOS: Playwright's WebKit doesn't start on this machine (it needs Ubuntu's ICU 74).
  • The Gmail and Outlook apps on real phones.

Open questions

  • Gendered forms: Segretario/Segretaria, Socio/Socia. Today the name from Auth is used as is.
  • Vicepresidente and Tesoriere already have a template entry (keys vicepresidente, tesoriere) but don't exist as roles in Auth yet.
  • The final PN logo URL: set SIGNATURE_LOGO_URL in production once it's published.
  • The template design: to refine together, as agreed.

🤖 Generated with Claude Code

Account › Email signature builds a signature to paste into Gmail, Outlook, Apple Mail
or Thunderbird, from a template for each kind of role the person holds: Carica
(Presidente, Segretario), Direttivo, Admin (Capo Admin, Admin), Team and Socio.

Name, email and roles come from the backend: board offices, Direttivo and Socio from
PoliNetwork Auth through the backend's new `me.roles`, Admin, Capo Admin and teams
from the People record. The person chooses the template, the roles shown, the layout
(side, stacked, compact) and the language, and may add pronouns, a phone number and
LinkedIn. The PoliNetwork logo and blue are fixed.

The HTML is built for mail clients: nested tables, inline styles, exact line heights,
an HTTPS PNG logo (`SIGNATURE_LOGO_URL`) sized in attributes, nothing they strip.
Copy signature puts rich HTML and plain text on the clipboard; the page also offers the
HTML code, the plain text and a .htm file for Outlook and Thunderbird.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant