From f950c33f79adc104794d58fe04429c176d569697 Mon Sep 17 00:00:00 2001
From: April John <waterdev@galaxycrow.de>
Date: Mon, 8 May 2023 11:36:32 +0200
Subject: [PATCH] fix: Detach push notifications.. ..from "isRead" check. Apps
 will handle that theself.

---
 packages/backend/src/services/create-notification.ts | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/packages/backend/src/services/create-notification.ts b/packages/backend/src/services/create-notification.ts
index e2dd3fc33..9bfd1a7bf 100644
--- a/packages/backend/src/services/create-notification.ts
+++ b/packages/backend/src/services/create-notification.ts
@@ -80,6 +80,9 @@ export async function createNotification(
 	setTimeout(async () => {
 		const fresh = await Notifications.findOneBy({ id: notification.id });
 		if (fresh == null) return; // 既に削除されているかもしれない
+		// We execute this before, because the server side "read" check doesnt work well with push notifications, the app and service worker will decide themself
+		// when it is best to show push notifications
+		pushNotification(notifieeId, "notification", packed);
 		if (fresh.isRead) return;
 
 		//#region ただしミュートしているユーザーからの通知なら無視
@@ -95,7 +98,6 @@ export async function createNotification(
 		//#endregion
 
 		publishMainStream(notifieeId, "unreadNotification", packed);
-		pushNotification(notifieeId, "notification", packed);
 
 		if (type === "follow")
 			sendEmailNotification.follow(