From e3c4a4391ce7124df52952bba42543fe98b3b188 Mon Sep 17 00:00:00 2001 From: Kyle Fang Date: Wed, 30 Mar 2022 22:55:01 +0800 Subject: [PATCH] fix: updating notification will trigger again --- functions/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/src/index.ts b/functions/src/index.ts index 4fee242..67278fd 100644 --- a/functions/src/index.ts +++ b/functions/src/index.ts @@ -51,7 +51,7 @@ async function checkUser(chatId: string, token: string) { }).then((r) => r.json()); for (const notification of notifications) { const sentRef = admin.database().ref(`/sent/${chatId}/${notification.id}`); - if ((await sentRef.get()).exists()) { + if ((await sentRef.get()).val() !== notification.updated_at) { continue; } await bot.telegram.sendMessage( @@ -60,7 +60,7 @@ async function checkUser(chatId: string, token: string) { notification.subject.title }\n\n${processUrl(notification.subject.url)}` ); - await sentRef.set(true); + await sentRef.set(notification.updated_at); } }