fix(notifications): tell staff about every new comment
Only the shot's assigned artist was notified of player comments, and client-link comments and pasted WhatsApp feedback notified no one. notifyCommentsAdded now notifies all active staff plus the shot/task artist, never the author, from all three paths. A pasted round becomes one notification per version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { db } from "@/lib/db";
|
||||
import { slackNotifyNewFeedback } from "@/lib/slack";
|
||||
import { notifyCommentsAdded } from "@/lib/notifications";
|
||||
import { validateReviewToken, getOrCreateReviewUser } from "@/lib/review-auth";
|
||||
|
||||
export async function POST(
|
||||
@@ -28,8 +29,8 @@ export async function POST(
|
||||
const version = await db.version.findUnique({
|
||||
where: { id: versionId },
|
||||
include: {
|
||||
shot: { select: { projectId: true, shotCode: true, project: { select: { slackWebhook: true } } } },
|
||||
task: { select: { projectId: true, title: true, project: { select: { slackWebhook: true } }, shot: { select: { shotCode: true } } } },
|
||||
shot: { select: { projectId: true, shotCode: true, artistId: true, project: { select: { slackWebhook: true } } } },
|
||||
task: { select: { projectId: true, title: true, assignedArtistId: true, project: { select: { slackWebhook: true } }, shot: { select: { shotCode: true } } } },
|
||||
},
|
||||
});
|
||||
const projectId = version?.shot?.projectId ?? version?.task?.projectId;
|
||||
@@ -70,6 +71,18 @@ export async function POST(
|
||||
});
|
||||
}
|
||||
|
||||
await notifyCommentsAdded({
|
||||
notes: [{
|
||||
versionId,
|
||||
shotCode,
|
||||
frameNumber,
|
||||
artistIds: [version.shot?.artistId, version.task?.assignedArtistId],
|
||||
}],
|
||||
authorId: user.id,
|
||||
authorName: user.name ?? user.email,
|
||||
origin: "client",
|
||||
}).catch((err) => console.error("[client comment] notify failed", err));
|
||||
|
||||
// canEdit mirrors the GET shape — a note you just wrote is always your own.
|
||||
return NextResponse.json({ comment: { ...comment, canEdit: true } }, { status: 201 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user