feat: Implement Novu topics for moderator notifications

This commit is contained in:
gpt-engineer-app[bot]
2025-10-12 18:20:02 +00:00
parent c359576f03
commit 825584d9b6
4 changed files with 238 additions and 5 deletions

View File

@@ -22,14 +22,21 @@ serve(async (req) => {
secretKey: novuApiKey
});
const { workflowId, subscriberId, payload, overrides } = await req.json();
const { workflowId, subscriberId, topicKey, payload, overrides } = await req.json();
console.log('Triggering notification:', { workflowId, subscriberId });
// Support both individual subscribers and topics
if (!subscriberId && !topicKey) {
throw new Error('Either subscriberId or topicKey must be provided');
}
const recipient = subscriberId
? { subscriberId }
: { topicKey };
console.log('Triggering notification:', { workflowId, recipient });
const result = await novu.trigger({
to: {
subscriberId,
},
to: recipient,
workflowId,
payload,
overrides,