mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 11:31:12 -05:00
feat: Implement moderator notifications
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user