feat: Implement moderator notifications

This commit is contained in:
gpt-engineer-app[bot]
2025-10-12 17:39:37 +00:00
parent 264a930c6a
commit 4b71f80939
6 changed files with 197 additions and 13 deletions

View File

@@ -327,6 +327,40 @@ class NotificationService {
}
}
/**
* Notify all moderators about a new submission
*/
async notifyModerators(payload: {
submission_id: string;
submission_type: string;
submitter_name: string;
action: string;
}): Promise<{ success: boolean; count: number; error?: string }> {
try {
const { data, error } = await supabase.functions.invoke('notify-moderators-submission', {
body: payload,
});
if (error) {
console.error('Edge function error notifying moderators:', error);
throw error;
}
console.log('Moderators notified successfully:', data);
return {
success: true,
count: data?.count || 0
};
} catch (error: unknown) {
console.error('Error notifying moderators:', error);
return {
success: false,
count: 0,
error: this.extractErrorMessage(error)
};
}
}
/**
* Check if Novu is enabled
*/