- Add notifications table with migration - Create NotificationService with area-of-interest matching - Integrate Mailgun for email delivery - Add notification API endpoints (get, mark as read, unread count) - Create scheduled jobs for event reminders and cleanup - Build NotificationBell component for frontend - Add notification triggers for reports and events - Implement comprehensive test script - Update Header with notification bell - Add email templates with HTML formatting Requirements satisfied: - 10.1: Users can define areas of interest (1-50km radius) - 10.2: Notifications sent within 10 minutes - 10.3: Notifications for new reports/events in user area - 10.4: Configurable notification preferences (email/in-app) Task 33 completed
26 lines
1.1 KiB
SQL
26 lines
1.1 KiB
SQL
-- CreateTable
|
|
CREATE TABLE `notifications` (
|
|
`id` VARCHAR(36) NOT NULL,
|
|
`user_id` VARCHAR(36) NOT NULL,
|
|
`type` ENUM('new_report', 'new_event', 'event_reminder', 'report_verified', 'report_disputed') NOT NULL,
|
|
`title` VARCHAR(255) NOT NULL,
|
|
`message` TEXT NOT NULL,
|
|
`related_id` VARCHAR(36) NULL COMMENT 'ID of related report or event',
|
|
`related_type` ENUM('report', 'event') NULL,
|
|
`latitude` DECIMAL(10, 8) NULL,
|
|
`longitude` DECIMAL(11, 8) NULL,
|
|
`read` BOOLEAN NOT NULL DEFAULT false,
|
|
`email_sent` BOOLEAN NOT NULL DEFAULT false,
|
|
`created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
|
|
|
|
INDEX `idx_user_id`(`user_id`),
|
|
INDEX `idx_created_at`(`created_at`),
|
|
INDEX `idx_read`(`read`),
|
|
INDEX `idx_type`(`type`),
|
|
INDEX `idx_lat_lng`(`latitude`, `longitude`),
|
|
PRIMARY KEY (`id`)
|
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE `notifications` ADD CONSTRAINT `notifications_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE NO ACTION;
|