Skip to content

override email feature - #1371

Merged
priosshrsth merged 5 commits into
productionfrom
main
Jul 3, 2026
Merged

override email feature#1371
priosshrsth merged 5 commits into
productionfrom
main

Conversation

@priosshrsth

Copy link
Copy Markdown
Collaborator
  • override email contents for some workspaces

cursor Bot and others added 4 commits July 2, 2026 11:08
* Handle expected Prisma request errors
* Warn on known Prisma errors instead of silencing them
…orkspaces (#1366)

* feat(notifications): evaluation-framed reminder emails for override workspaces
@priosshrsth priosshrsth self-assigned this Jul 3, 2026
@vercel

vercel Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tasks-app Ready Ready Preview, Comment Jul 3, 2026 10:39am

Request Review

@priosshrsth
priosshrsth marked this pull request as ready for review July 3, 2026 10:38
@vercel

vercel Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Deployment failed with the following error:

Deploying Serverless Functions to multiple regions is restricted to the Pro and Enterprise plans.

Learn More: https://vercel.link/multiple-function-regions

@greptile-apps

greptile-apps Bot commented Jul 3, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds a workspace-level email override for reminder notifications, replacing the generic task reminder copy with mystery-shop-evaluation-specific HTML content (htmlBody) for opted-in workspaces. An evaluationTitle derived from the task title (with an "Action Required: " prefix stripped) is HTML-escaped and embedded in the body; standard workspaces are entirely unaffected.

  • notification.helpers.ts gains an optional evaluationTitle param and a local escapeHtml helper; all six reminder variants conditionally populate htmlBody.
  • send-reminder-email.ts detects override workspaces, computes evaluationTitle, and dispatches either the HTML override email or the existing plain-text email.
  • Tests cover XSS escaping, the prefix-stripping behaviour, and snapshot updates for the new htmlBody field.

Confidence Score: 4/5

Safe to merge for non-override workspaces; the override path is well-tested but carries a small risk of a body-less email for pathological task titles.

The XSS escaping is correct and tested, the standard email path is untouched, and the test suite is thorough. The two concerns are narrow: the "Action Required: " strip uses an unanchored string replace (could silently mangle titles that contain the phrase mid-string), and if stripping the prefix leaves an empty string the resulting override email will have neither body nor htmlBody. Both are edge cases unlikely to be hit in production, but neither is guarded against in the code.

src/jobs/notifications/send-reminder-email.ts — the evaluationTitle derivation logic around line 36.

Important Files Changed

Filename Overview
src/app/api/notification/notification.helpers.ts Adds optional evaluationTitle param and htmlBody to every reminder variant; escapeHtml correctly sanitises the title before embedding it in HTML.
src/jobs/notifications/send-reminder-email.ts Override path computes evaluationTitle by stripping a hardcoded "Action Required: " prefix; if stripping yields an empty string the email is sent with no body or htmlBody.
src/app/api/notification/notification.helpers.test.ts New tests cover: undefined htmlBody when no evaluationTitle, evaluation prose when title is supplied, and HTML-escaping of the title.
src/jobs/notifications/send-reminder-email.test.ts Tests verify override subject/header/title/htmlBody, "Action Required:" prefix stripping, and that non-override workspaces are unaffected.
src/app/api/notification/snapshots/notification.helpers.test.ts.snap Snapshot updated to include htmlBody: undefined for all existing test variants, consistent with the new optional field.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[sendReminderEmail called] --> B{workspace in\noverrideWorkspaces?}
    B -- No --> C[getReminderEmailDetails\nno evaluationTitle]
    C --> D[email: standard subject/header/title/body]
    B -- Yes --> E[compute displayTitle\nvia reminderSubjectSearch replace]
    E --> F[compute evaluationTitle\nstrip 'Action Required: ' prefix]
    F --> G[getReminderEmailDetails\nwith evaluationTitle]
    G --> H{evaluationTitle\ntruthy?}
    H -- Yes --> I[htmlBody: mystery shop\nevaluation HTML]
    H -- No --> J[htmlBody: undefined]
    I --> K[email: custom header/title\n+ htmlBody, no body]
    J --> L[email: custom header/title\n+ htmlBody undefined, no body]
    K --> M[copilot.createNotification]
    L --> M
    D --> M
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[sendReminderEmail called] --> B{workspace in\noverrideWorkspaces?}
    B -- No --> C[getReminderEmailDetails\nno evaluationTitle]
    C --> D[email: standard subject/header/title/body]
    B -- Yes --> E[compute displayTitle\nvia reminderSubjectSearch replace]
    E --> F[compute evaluationTitle\nstrip 'Action Required: ' prefix]
    F --> G[getReminderEmailDetails\nwith evaluationTitle]
    G --> H{evaluationTitle\ntruthy?}
    H -- Yes --> I[htmlBody: mystery shop\nevaluation HTML]
    H -- No --> J[htmlBody: undefined]
    I --> K[email: custom header/title\n+ htmlBody, no body]
    J --> L[email: custom header/title\n+ htmlBody undefined, no body]
    K --> M[copilot.createNotification]
    L --> M
    D --> M
Loading

Reviews (1): Last reviewed commit: "Merge branch 'production' into main" | Re-trigger Greptile

Comment thread src/jobs/notifications/send-reminder-email.ts
Comment thread src/jobs/notifications/send-reminder-email.ts
@priosshrsth
priosshrsth merged commit 9ed8138 into production Jul 3, 2026
3 checks passed
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.

2 participants