From eb5a402cde35f8d065a7a944bcbab08abbac70ce Mon Sep 17 00:00:00 2001 From: CyberL1 Date: Sun, 21 Apr 2024 21:36:36 +0200 Subject: [PATCH] feat: notifications --- .../Controllers/NotificationsController.cs | 76 +++++++++++++++++++ .../Migrations/DataContextModelSnapshot.cs | 14 ++-- 2 files changed, 83 insertions(+), 7 deletions(-) create mode 100644 MyMcRealms/Controllers/NotificationsController.cs diff --git a/MyMcRealms/Controllers/NotificationsController.cs b/MyMcRealms/Controllers/NotificationsController.cs new file mode 100644 index 0000000..b91a3cb --- /dev/null +++ b/MyMcRealms/Controllers/NotificationsController.cs @@ -0,0 +1,76 @@ +using Microsoft.AspNetCore.Mvc; +using MyMcRealms.Attributes; + +// TODO: Add Notification typing class +namespace MyMcRealms.Controllers +{ + [Route("[controller]")] + [ApiController] + [RequireMinecraftCookie] + public class NotificationsController : ControllerBase + { + [HttpGet] + public Object GetNotifications() + { + var n1 = new + { + NotificationUuid = "8e19f84925bf4efbacec9bed53d74696", + Dismissable = true, + Seen = false, + Type = "visitUrl", + Url = "https://my-mc.link/", + ButtonText = new + { + TranslationKey = "mco.notification.visitUrl.message.default", + Args = new List { } + }, + Message = new { + TranslationKey = "mco.notification.visitUrl.message.default", + Args = new List { } + } + }; + + var n2 = new { + NotificationUuid = "8e116d026aa643b394a2dfbcaaabb7ff", + Dismissable = true, + Seen = false, + Type = "infoPopup", + Title = new { + TranslationKey = "mco.notification.visitUrl.message.default", + Args = new List { } + }, + Message = new { + TranslationKey = "mco.notification.visitUrl.message.default", + Args = new List { } + }, + Image = "notification/1", + UrlButton = new { + Url = "https://my-mc.link/", + UrlText = new { + TranslationKey = "mco.notification.visitUrl.message.default", + Args = new List { } + } + } + }; + + var notifs = new + { + Notifications = /* new List { n1, n2 } */ new List { } + }; + + return notifs; + } + + [HttpPost("seen")] + public List MarkAsSeenNotifications() + { + return []; + } + + [HttpPost("dissmiss")] + public List DissmissNotifications() + { + return []; + } + } +} \ No newline at end of file diff --git a/MyMcRealms/Migrations/DataContextModelSnapshot.cs b/MyMcRealms/Migrations/DataContextModelSnapshot.cs index 94db4f3..0995620 100644 --- a/MyMcRealms/Migrations/DataContextModelSnapshot.cs +++ b/MyMcRealms/Migrations/DataContextModelSnapshot.cs @@ -52,7 +52,7 @@ namespace MyMcRealms.Migrations b.HasIndex("WorldId"); - b.ToTable("Backups"); + b.ToTable("Backups", (string)null); }); modelBuilder.Entity("MyMcRealms.Entities.Configuration", b => @@ -66,7 +66,7 @@ namespace MyMcRealms.Migrations b.HasKey("Key"); - b.ToTable("Configuration"); + b.ToTable("Configuration", (string)null); }); modelBuilder.Entity("MyMcRealms.Entities.Connection", b => @@ -91,7 +91,7 @@ namespace MyMcRealms.Migrations b.HasIndex("WorldId"); - b.ToTable("Connections"); + b.ToTable("Connections", (string)null); }); modelBuilder.Entity("MyMcRealms.Entities.Invite", b => @@ -120,7 +120,7 @@ namespace MyMcRealms.Migrations b.HasIndex("WorldId"); - b.ToTable("Invites"); + b.ToTable("Invites", (string)null); }); modelBuilder.Entity("MyMcRealms.Entities.Player", b => @@ -159,7 +159,7 @@ namespace MyMcRealms.Migrations b.HasIndex("WorldId"); - b.ToTable("Players"); + b.ToTable("Players", (string)null); }); modelBuilder.Entity("MyMcRealms.Entities.Subscription", b => @@ -185,7 +185,7 @@ namespace MyMcRealms.Migrations b.HasIndex("WorldId") .IsUnique(); - b.ToTable("Subscriptions"); + b.ToTable("Subscriptions", (string)null); }); modelBuilder.Entity("MyMcRealms.Entities.World", b => @@ -240,7 +240,7 @@ namespace MyMcRealms.Migrations b.HasKey("Id"); - b.ToTable("Worlds"); + b.ToTable("Worlds", (string)null); }); modelBuilder.Entity("MyMcRealms.Entities.Backup", b =>