diff options
| author | tamaina <tamaina@hotmail.co.jp> | 2022-07-10 15:15:21 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-10 15:15:21 +0900 |
| commit | 83ebe79a3fe5ddb22e80d3b47b9e8ec0701286ad (patch) | |
| tree | 55ebb5ef0e28f3ae2ccc68b0565372815fad926e /packages/sw/src | |
| parent | fix(client): fix style of mention (diff) | |
| download | misskey-83ebe79a3fe5ddb22e80d3b47b9e8ec0701286ad.tar.gz misskey-83ebe79a3fe5ddb22e80d3b47b9e8ec0701286ad.tar.bz2 misskey-83ebe79a3fe5ddb22e80d3b47b9e8ec0701286ad.zip | |
enhance(sw): If receiving a push notification issued more than a day, ignore it. (#8980)
* enhance(sw): ignore old push notification
* :v:
* 半日
* !==
* 1日
Diffstat (limited to 'packages/sw/src')
| -rw-r--r-- | packages/sw/src/sw.ts | 6 | ||||
| -rw-r--r-- | packages/sw/src/types.ts | 1 |
2 files changed, 6 insertions, 1 deletions
diff --git a/packages/sw/src/sw.ts b/packages/sw/src/sw.ts index 0ba6a6e4af..872692f903 100644 --- a/packages/sw/src/sw.ts +++ b/packages/sw/src/sw.ts @@ -42,8 +42,12 @@ self.addEventListener('push', ev => { // case 'driveFileCreated': case 'notification': case 'unreadMessagingMessage': + // 1日以上経過している場合は無視 + if ((new Date()).getTime() - data.dateTime > 1000 * 60 * 60 * 24) break; + // クライアントがあったらストリームに接続しているということなので通知しない - if (clients.length != 0) return; + if (clients.length !== 0) break; + return createNotification(data); case 'readAllNotifications': for (const n of await self.registration.getNotifications()) { diff --git a/packages/sw/src/types.ts b/packages/sw/src/types.ts index 6aa3726eac..0404e21e57 100644 --- a/packages/sw/src/types.ts +++ b/packages/sw/src/types.ts @@ -24,6 +24,7 @@ export type pushNotificationData<K extends keyof pushNotificationDataSourceMap> type: K; body: pushNotificationDataSourceMap[K]; userId: string; + dateTime: number; }; export type pushNotificationDataMap = { |