summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authortamaina <tamaina@hotmail.co.jp>2024-02-23 17:19:08 +0900
committerGitHub <noreply@github.com>2024-02-23 17:19:08 +0900
commitb8d8b359bc8a6c542d78b86f500e0f45f63f48fb (patch)
tree38ea8cd097d30bbab73d0850f74730ba2d9f167e /packages
parentFix(frontend): 絵文字オートコンプリートの優先順位がおか... (diff)
downloadsharkey-b8d8b359bc8a6c542d78b86f500e0f45f63f48fb.tar.gz
sharkey-b8d8b359bc8a6c542d78b86f500e0f45f63f48fb.tar.bz2
sharkey-b8d8b359bc8a6c542d78b86f500e0f45f63f48fb.zip
fix: プッシュ通知の変更が1時間ほど反映されない問題を修正 (#13407)
* fix: プッシュ通知の変更が1時間ほど反映されない問題を修正 * 410 to refresh * refreshCache
Diffstat (limited to 'packages')
-rw-r--r--packages/backend/src/core/PushNotificationService.ts7
-rw-r--r--packages/backend/src/server/api/endpoints/sw/register.ts4
-rw-r--r--packages/backend/src/server/api/endpoints/sw/unregister.ts7
-rw-r--r--packages/backend/src/server/api/endpoints/sw/update-registration.ts5
4 files changed, 23 insertions, 0 deletions
diff --git a/packages/backend/src/core/PushNotificationService.ts b/packages/backend/src/core/PushNotificationService.ts
index e630539fbc..3b706d9854 100644
--- a/packages/backend/src/core/PushNotificationService.ts
+++ b/packages/backend/src/core/PushNotificationService.ts
@@ -115,6 +115,8 @@ export class PushNotificationService implements OnApplicationShutdown {
endpoint: subscription.endpoint,
auth: subscription.auth,
publickey: subscription.publickey,
+ }).then(() => {
+ this.refreshCache(userId);
});
}
});
@@ -122,6 +124,11 @@ export class PushNotificationService implements OnApplicationShutdown {
}
@bindThis
+ public refreshCache(userId: string): void {
+ this.subscriptionsCache.refresh(userId);
+ }
+
+ @bindThis
public dispose(): void {
this.subscriptionsCache.dispose();
}
diff --git a/packages/backend/src/server/api/endpoints/sw/register.ts b/packages/backend/src/server/api/endpoints/sw/register.ts
index 06c04b3f9a..a9a33149f9 100644
--- a/packages/backend/src/server/api/endpoints/sw/register.ts
+++ b/packages/backend/src/server/api/endpoints/sw/register.ts
@@ -9,6 +9,7 @@ import type { SwSubscriptionsRepository } from '@/models/_.js';
import { Endpoint } from '@/server/api/endpoint-base.js';
import { MetaService } from '@/core/MetaService.js';
import { DI } from '@/di-symbols.js';
+import { PushNotificationService } from '@/core/PushNotificationService.js';
export const meta = {
tags: ['account'],
@@ -66,6 +67,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
private idService: IdService,
private metaService: MetaService,
+ private pushNotificationService: PushNotificationService,
) {
super(meta, paramDef, async (ps, me) => {
// if already subscribed
@@ -97,6 +99,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
sendReadMessage: ps.sendReadMessage,
});
+ this.pushNotificationService.refreshCache(me.id);
+
return {
state: 'subscribed' as const,
key: instance.swPublicKey,
diff --git a/packages/backend/src/server/api/endpoints/sw/unregister.ts b/packages/backend/src/server/api/endpoints/sw/unregister.ts
index 2bc91c7278..2edf7fab1b 100644
--- a/packages/backend/src/server/api/endpoints/sw/unregister.ts
+++ b/packages/backend/src/server/api/endpoints/sw/unregister.ts
@@ -7,6 +7,7 @@ import { Inject, Injectable } from '@nestjs/common';
import type { SwSubscriptionsRepository } from '@/models/_.js';
import { Endpoint } from '@/server/api/endpoint-base.js';
import { DI } from '@/di-symbols.js';
+import { PushNotificationService } from '@/core/PushNotificationService.js';
export const meta = {
tags: ['account'],
@@ -29,12 +30,18 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
constructor(
@Inject(DI.swSubscriptionsRepository)
private swSubscriptionsRepository: SwSubscriptionsRepository,
+
+ private pushNotificationService: PushNotificationService,
) {
super(meta, paramDef, async (ps, me) => {
await this.swSubscriptionsRepository.delete({
...(me ? { userId: me.id } : {}),
endpoint: ps.endpoint,
});
+
+ if (me) {
+ this.pushNotificationService.refreshCache(me.id);
+ }
});
}
}
diff --git a/packages/backend/src/server/api/endpoints/sw/update-registration.ts b/packages/backend/src/server/api/endpoints/sw/update-registration.ts
index b56b07fd00..839a07c770 100644
--- a/packages/backend/src/server/api/endpoints/sw/update-registration.ts
+++ b/packages/backend/src/server/api/endpoints/sw/update-registration.ts
@@ -7,6 +7,7 @@ import { Inject, Injectable } from '@nestjs/common';
import type { SwSubscriptionsRepository } from '@/models/_.js';
import { Endpoint } from '@/server/api/endpoint-base.js';
import { DI } from '@/di-symbols.js';
+import { PushNotificationService } from '@/core/PushNotificationService.js';
import { ApiError } from '../../error.js';
export const meta = {
@@ -58,6 +59,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
constructor(
@Inject(DI.swSubscriptionsRepository)
private swSubscriptionsRepository: SwSubscriptionsRepository,
+
+ private pushNotificationService: PushNotificationService,
) {
super(meta, paramDef, async (ps, me) => {
const swSubscription = await this.swSubscriptionsRepository.findOneBy({
@@ -77,6 +80,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
sendReadMessage: swSubscription.sendReadMessage,
});
+ this.pushNotificationService.refreshCache(me.id);
+
return {
userId: swSubscription.userId,
endpoint: swSubscription.endpoint,