using Nuuru.Server.DTOs.Notification; using Nuuru.Server.Models; namespace Nuuru.Server.Extensions { public static class NotificationMappingExtensions { public static NotificationDto ToDto(this Notification notification) { return new NotificationDto { Id = notification.Id, Type = notification.Type switch { NotificationType.CommentOnPost => "comment", NotificationType.Mention => "mention", NotificationType.SystemAnnouncement => "announcement", NotificationType.PostApproved => "post_approved", NotificationType.PostRejected => "post_rejected", NotificationType.ReportResolved => "report_resolved", NotificationType.ReportDismissed => "report_dismissed", NotificationType.PrivateMessage => "private_message", NotificationType.GroupMessage => "group_message", NotificationType.WatchedPostComment => "watched_post_comment", NotificationType.WatchedThreadReply => "watched_thread_reply", NotificationType.PostTrashed => "post_trashed", NotificationType.PostRestored => "post_restored", NotificationType.ForumQuote => "forum_quote", NotificationType.Reaction => "reaction", _ => "unknown" }, Message = notification.Message, CreatedAt = notification.CreatedAt, IsRead = notification.IsRead, RelatedPostId = notification.RelatedPostId, RelatedCommentId = notification.RelatedCommentId, RelatedForumPostId = notification.RelatedForumPostId, RelatedForumThreadId = notification.RelatedForumThreadId, RelatedForumCategorySlug = notification.RelatedForumCategorySlug, RelatedConversationId = notification.RelatedConversationId, RelatedMessageId = notification.RelatedMessageId, ReactionEmoteName = notification.ReactionEmoteName, TriggeredBy = notification.TriggeredByUser?.ToUploaderDto() }; } public static List ToDto(this IEnumerable notifications) { return notifications.Select(n => n.ToDto()).ToList(); } } }