Add internal endpoint for task status change notifications#2166
Add internal endpoint for task status change notifications#2166
Conversation
Adds POST /v1/internal/tasks/notify-status-change so enterprise-api can delegate email + in-app notifications to the comp API instead of duplicating Resend infrastructure. Makes changedByUserId optional in TaskNotifierService.notifyStatusChange() with 'Automation' fallback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PR SummaryMedium Risk Overview Updates Written by Cursor Bugbot for commit 318cb35. This will update automatically on new commits. Configure here. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Adds @IsString() and @IsEnum() decorators so the global ValidationPipe doesn't reject all requests. Throws InternalServerErrorException instead of returning 200 with { success: false } on notification failures. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Notify users when ANY automation fails (not just when all fail). New email template, service method, and internal endpoint for automation-specific failure notifications. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Prevents stale validation when new statuses are added to the schema. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| ); | ||
|
|
||
| const organizationName = organization?.name ?? 'your organization'; | ||
| const changedByName = 'Automation'; |
There was a problem hiding this comment.
Unused changedByName variable is dead code
Low Severity
In notifyAutomationFailures, changedByName is assigned 'Automation' but never referenced anywhere in the method. The email template AutomationFailuresEmail doesn't accept a changedByName prop, and the in-app notification message is constructed without it. This appears to be a leftover from copying the notifyStatusChange pattern where changedByName is actually used in the email template and Novu payload.


Summary
POST /v1/internal/tasks/notify-status-changeinternal endpoint so enterprise-api can delegate task notification delivery (email + in-app) to the comp APIchangedByUserIdoptional inTaskNotifierService.notifyStatusChange()— when omitted, uses'Automation'as the actor name and skips user lookupWhat changed
apps/api/src/tasks/internal-task-notification.controller.ts(new) — Internal controller guarded byInternalTokenGuard, accepts{ organizationId, taskId, taskTitle, oldStatus, newStatus }apps/api/src/tasks/tasks.module.ts— Registered new controllerapps/api/src/tasks/task-notifier.service.ts— MadechangedByUserIdoptional with conditional DB lookup and'Automation'fallback nameDepends on / Related
Test plan
tsc --noEmit)POST /v1/internal/tasks/notify-status-changewith validX-Internal-Tokensends email + in-app notificationnotifyStatusChange()calls withchangedByUserIdstill work unchanged🤖 Generated with Claude Code