Skip to content

Add internal endpoint for task status change notifications#2166

Merged
tofikwest merged 5 commits intomainfrom
tofik/centralize-task-status-notifications
Feb 19, 2026
Merged

Add internal endpoint for task status change notifications#2166
tofikwest merged 5 commits intomainfrom
tofik/centralize-task-status-notifications

Conversation

@tofikwest
Copy link
Contributor

Summary

  • Adds POST /v1/internal/tasks/notify-status-change internal endpoint so enterprise-api can delegate task notification delivery (email + in-app) to the comp API
  • Makes changedByUserId optional in TaskNotifierService.notifyStatusChange() — when omitted, uses 'Automation' as the actor name and skips user lookup
  • This centralizes all notification infrastructure (Resend + Novu) in the comp API instead of duplicating it in enterprise-api

What changed

  • apps/api/src/tasks/internal-task-notification.controller.ts (new) — Internal controller guarded by InternalTokenGuard, accepts { organizationId, taskId, taskTitle, oldStatus, newStatus }
  • apps/api/src/tasks/tasks.module.ts — Registered new controller
  • apps/api/src/tasks/task-notifier.service.ts — Made changedByUserId optional with conditional DB lookup and 'Automation' fallback name

Depends on / Related

Test plan

  • Type check passes (tsc --noEmit)
  • Calling POST /v1/internal/tasks/notify-status-change with valid X-Internal-Token sends email + in-app notification
  • Calling without token returns 401
  • Existing notifyStatusChange() calls with changedByUserId still work unchanged

🤖 Generated with Claude Code

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>
@cursor
Copy link

cursor bot commented Feb 18, 2026

PR Summary

Medium Risk
Adds new internal API surfaces that can trigger outbound email/in-app notifications; mistakes in guarding, recipient selection, or payload values could spam users or leak task metadata, though access is protected by InternalTokenGuard.

Overview
Adds a new internal, InternalTokenGuard-protected controller exposing POST /v1/internal/tasks/notify-status-change and POST /v1/internal/tasks/notify-automation-failures to trigger task notifications without a user actor.

Updates TaskNotifierService.notifyStatusChange to make changedByUserId optional (skipping user lookup and using "Automation" as the actor when absent), and adds notifyAutomationFailures which sends both email (new AutomationFailuresEmail template) and in-app Novu notifications to the task assignee plus org admins/owners, honoring unsubscribe preferences. The OpenAPI spec is updated accordingly and the new controller is wired into TasksModule.

Written by Cursor Bugbot for commit 318cb35. This will update automatically on new commits. Configure here.

@vercel
Copy link

vercel bot commented Feb 18, 2026

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

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
app Skipped Skipped Feb 19, 2026 4:33am
portal Skipped Skipped Feb 19, 2026 4:33am

Request Review

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>
@vercel vercel bot temporarily deployed to Preview – app February 18, 2026 22:51 Inactive
@vercel vercel bot temporarily deployed to Preview – portal February 18, 2026 22:51 Inactive
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>
@vercel vercel bot temporarily deployed to Preview – portal February 19, 2026 04:17 Inactive
@vercel vercel bot temporarily deployed to Preview – app February 19, 2026 04:17 Inactive
Prevents stale validation when new statuses are added to the schema.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel vercel bot temporarily deployed to Preview – app February 19, 2026 04:33 Inactive
@vercel vercel bot temporarily deployed to Preview – portal February 19, 2026 04:33 Inactive
@tofikwest tofikwest merged commit 97cebf8 into main Feb 19, 2026
14 checks passed
@tofikwest tofikwest deleted the tofik/centralize-task-status-notifications branch February 19, 2026 04:39
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

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

Comments