From 69b32f43b5b42553a9129453ee314d8f38b49954 Mon Sep 17 00:00:00 2001 From: Aelita4 Date: Fri, 22 Nov 2024 15:26:28 +0100 Subject: [PATCH] Add simple mail system --- public/mail-notif.svg | 6 ++++ public/mail.svg | 4 +++ src/components/NavBar.astro | 16 +++++++++- src/lib/classes/managers/FleetManager.ts | 33 ++++++++++++++++++++- src/lib/db/mails.ts | 33 +++++++++++++++++++++ src/lib/db/mongodb.ts | 5 ++++ src/pages/game/mail.astro | 37 ++++++++++++++++++++++++ src/types/db/DBMail.ts | 11 +++++++ 8 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 public/mail-notif.svg create mode 100644 public/mail.svg create mode 100644 src/lib/db/mails.ts create mode 100644 src/pages/game/mail.astro create mode 100644 src/types/db/DBMail.ts diff --git a/public/mail-notif.svg b/public/mail-notif.svg new file mode 100644 index 0000000..8c6c015 --- /dev/null +++ b/public/mail-notif.svg @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/public/mail.svg b/public/mail.svg new file mode 100644 index 0000000..4c70db9 --- /dev/null +++ b/public/mail.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/components/NavBar.astro b/src/components/NavBar.astro index 8faf30c..eb93594 100644 --- a/src/components/NavBar.astro +++ b/src/components/NavBar.astro @@ -1,4 +1,6 @@ --- +import { ObjectId } from 'mongodb'; +import { checkForUnreadMails } from '../lib/db/mails'; import { getHighestWeightedLanguage, getLocales, getName } from '../lib/utils/langDriver'; interface Props { @@ -133,6 +135,9 @@ const topRow = filteredList.filter(element => element.position === "top"); const bottomRow = filteredList.filter(element => element.position === "bottom"); const username = Astro.cookies.get('username')?.value ?? ""; +const userId = Astro.cookies.get('userid')?.value ?? 0; + +const hasUnreadMail = await checkForUnreadMails(new ObjectId(userId)); ---