From e6f8853b49726cb7fd59d11d4e7cde0d9771d614 Mon Sep 17 00:00:00 2001 From: Glax Date: Mon, 16 Dec 2024 20:14:28 +0100 Subject: [PATCH] Add NotificationUrgency.cs --- API/Program.cs | 2 +- API/Schema/Notification.cs | 4 ++-- API/Schema/NotificationUrgency.cs | 8 ++++++++ 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 API/Schema/NotificationUrgency.cs diff --git a/API/Program.cs b/API/Program.cs index cf074ed..5f414ab 100644 --- a/API/Program.cs +++ b/API/Program.cs @@ -120,7 +120,7 @@ using (var scope = app.Services.CreateScope()) context.Jobs.RemoveRange(context.Jobs.Where(j => j.state == JobState.Completed && j.RecurrenceMs < 1)); string[] emojis = { "(•‿•)", "(づ \u25d5‿\u25d5 )づ", "( \u02d8\u25bd\u02d8)っ\u2668", "=\uff3e\u25cf \u22cf \u25cf\uff3e=", "(ΦωΦ)", "(\u272a\u3268\u272a)", "( ノ・o・ )ノ", "(〜^\u2207^ )〜", "~(\u2267ω\u2266)~","૮ \u00b4• ﻌ \u00b4• ა", "(\u02c3ᆺ\u02c2)", "(=\ud83d\udf66 \u0f1d \ud83d\udf66=)"}; - context.Notifications.Add(new Notification("Tranga Started", emojis[Random.Shared.Next(0, emojis.Length - 1)], 2)); + context.Notifications.Add(new Notification("Tranga Started", emojis[Random.Shared.Next(0, emojis.Length - 1)], NotificationUrgency.High)); context.SaveChanges(); diff --git a/API/Schema/Notification.cs b/API/Schema/Notification.cs index 13a1e30..ec7bae8 100644 --- a/API/Schema/Notification.cs +++ b/API/Schema/Notification.cs @@ -4,12 +4,12 @@ using Microsoft.EntityFrameworkCore; namespace API.Schema; [PrimaryKey("NotificationId")] -public class Notification(string title, string message = "", byte urgency = 2, DateTime? date = null) +public class Notification(string title, string message = "", NotificationUrgency urgency = NotificationUrgency.Normal, DateTime? date = null) { [MaxLength(64)] public string NotificationId { get; init; } = TokenGen.CreateToken("Notification", 64); - public byte Urgency { get; init; } = urgency; + public NotificationUrgency Urgency { get; init; } = urgency; public string Title { get; init; } = title; diff --git a/API/Schema/NotificationUrgency.cs b/API/Schema/NotificationUrgency.cs new file mode 100644 index 0000000..711f1f0 --- /dev/null +++ b/API/Schema/NotificationUrgency.cs @@ -0,0 +1,8 @@ +namespace API.Schema; + +public enum NotificationUrgency : byte +{ + Low = 1, + Normal = 3, + High = 5 +} \ No newline at end of file