import mongoose, { Schema, Document } from 'mongoose'; export type NotificationType = 'info' | 'warning' | 'error' | 'success'; export interface INotification extends Document { organizationId: string; recipientId?: string; // Se null, é para todos da organização title: string; message: string; type: NotificationType; isRead: boolean; isArchived: boolean; archivedBy: string[]; // IDs dos usuários que arquivaram (para notificações globais) deletedBy: string[]; // IDs dos usuários que deletaram (para notificações globais) metadata?: any; // Para guardar IDs de projetos, itens, etc. createdAt: Date; } const NotificationSchema: Schema = new Schema({ organizationId: { type: String, required: true, index: true }, recipientId: { type: String, index: true }, // Opcional title: { type: String, required: true }, message: { type: String, required: true }, type: { type: String, enum: ['info', 'warning', 'error', 'success'], default: 'info' }, isRead: { type: Boolean, default: false }, isArchived: { type: Boolean, default: false }, archivedBy: [{ type: String }], deletedBy: [{ type: String }], metadata: { type: Schema.Types.Mixed }, }, { timestamps: true }); export default mongoose.models.Notification || mongoose.model('Notification', NotificationSchema);