From cef7c5f7b038d98e06276c8c180b8709df12ffed Mon Sep 17 00:00:00 2001 From: pikiou Date: Tue, 5 Apr 2022 01:45:52 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20notification=20tiny=20bug=C2=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Asks/AskParticipationDetails.tsx | 2 +- src/server/notifications.ts | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/components/Asks/AskParticipationDetails.tsx b/src/components/Asks/AskParticipationDetails.tsx index 132a07f..8c21f81 100644 --- a/src/components/Asks/AskParticipationDetails.tsx +++ b/src/components/Asks/AskParticipationDetails.tsx @@ -21,7 +21,7 @@ export function AskParticipationDetails(asks: JSX.Element[], id: number): void { const [participationDetails] = useUserParticipationDetails() const tshirtSize = get(participationDetails, "tshirtSize", "") const food = get(participationDetails, "food", "") - const needToShow = !tshirtSize && !food + const needToShow = !tshirtSize || !food addAsk( asks, diff --git a/src/server/notifications.ts b/src/server/notifications.ts index 8ec2a28..393bba3 100644 --- a/src/server/notifications.ts +++ b/src/server/notifications.ts @@ -1,3 +1,4 @@ +import { lowerFirst } from "lodash" import { Request, Response, NextFunction } from "express" import webpush from "web-push" import { @@ -107,10 +108,7 @@ async function notifyAboutAnnouncement(): Promise { } const audience = volunteerList.filter( - (v) => - v.acceptsNotifs === "oui" && - !v.discordId && - (v.active === "oui" || v.active === "peut-etre") + (v) => v.acceptsNotifs === "oui" && (v.active === "oui" || v.active === "peut-etre") ) console.error( @@ -119,10 +117,17 @@ async function notifyAboutAnnouncement(): Promise { .join(", ")}` ) + const announceDescription: string = + { + gazette: / - /.test(toSend.title) + ? `la ${lowerFirst(toSend.title.replace(/.* - /, ""))}` + : `la gazette ${lowerFirst(toSend.title)}`, + "compte rendu": `le compte-rendu du ${lowerFirst(toSend.title)}`, + }[toSend.type] || toSend.title + audience.forEach((v) => { sendNotifToVolunteer(v, { - message: - "Clique-moi pour voir la gazette de février dans la page Annonces !\n\nFini les emails/spam, cette notification est notre nouveau moyen de te prévenir :)", + message: `Clique-moi pour voir ${announceDescription}`, }) })