diff options
| author | lqvp <183242690+lqvp@users.noreply.github.com> | 2025-02-11 10:15:33 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-11 01:15:33 +0000 |
| commit | e3392936736c16000b837f1549943d2f241e01b2 (patch) | |
| tree | 6b2c743e5982e990ce6ec832706f95642eccb6dd /packages/backend/src | |
| parent | fix(frontend): コンディショナルロールを手動で割り当てで... (diff) | |
| download | misskey-e3392936736c16000b837f1549943d2f241e01b2.tar.gz misskey-e3392936736c16000b837f1549943d2f241e01b2.tar.bz2 misskey-e3392936736c16000b837f1549943d2f241e01b2.zip | |
feat: アクセストークン発行時に通知するように (#15422)
* feat: アクセストークン発行時に通知するように (misskey-dev/misskey#13353)
* fix: 不要な翻訳を削除/インデントを揃えるように
* chore(backend): 不要なawaitを削除
* chore: changelogへ追加
Diffstat (limited to 'packages/backend/src')
| -rw-r--r-- | packages/backend/src/models/Notification.ts | 4 | ||||
| -rw-r--r-- | packages/backend/src/models/json-schema/notification.ts | 10 | ||||
| -rw-r--r-- | packages/backend/src/server/api/endpoints/miauth/gen-token.ts | 5 | ||||
| -rw-r--r-- | packages/backend/src/types.ts | 2 |
4 files changed, 21 insertions, 0 deletions
diff --git a/packages/backend/src/models/Notification.ts b/packages/backend/src/models/Notification.ts index b7f8e94d69..5772ace338 100644 --- a/packages/backend/src/models/Notification.ts +++ b/packages/backend/src/models/Notification.ts @@ -91,6 +91,10 @@ export type MiNotification = { id: string; createdAt: string; } | { + type: 'createToken'; + id: string; + createdAt: string; +} | { type: 'app'; id: string; createdAt: string; diff --git a/packages/backend/src/models/json-schema/notification.ts b/packages/backend/src/models/json-schema/notification.ts index cddaf4bc83..1638b2b3c7 100644 --- a/packages/backend/src/models/json-schema/notification.ts +++ b/packages/backend/src/models/json-schema/notification.ts @@ -339,6 +339,16 @@ export const packedNotificationSchema = { type: { type: 'string', optional: false, nullable: false, + enum: ['createToken'], + }, + }, + }, { + type: 'object', + properties: { + ...baseSchema.properties, + type: { + type: 'string', + optional: false, nullable: false, enum: ['app'], }, body: { diff --git a/packages/backend/src/server/api/endpoints/miauth/gen-token.ts b/packages/backend/src/server/api/endpoints/miauth/gen-token.ts index fc9a8f3ebe..f1e3726641 100644 --- a/packages/backend/src/server/api/endpoints/miauth/gen-token.ts +++ b/packages/backend/src/server/api/endpoints/miauth/gen-token.ts @@ -7,6 +7,7 @@ import { Inject, Injectable } from '@nestjs/common'; import { Endpoint } from '@/server/api/endpoint-base.js'; import type { AccessTokensRepository } from '@/models/_.js'; import { IdService } from '@/core/IdService.js'; +import { NotificationService } from '@/core/NotificationService.js'; import { secureRndstr } from '@/misc/secure-rndstr.js'; import { DI } from '@/di-symbols.js'; @@ -50,6 +51,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- private accessTokensRepository: AccessTokensRepository, private idService: IdService, + private notificationService: NotificationService, ) { super(meta, paramDef, async (ps, me) => { // Generate access token @@ -71,6 +73,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- permission: ps.permission, }); + // アクセストークンが生成されたことを通知 + this.notificationService.createNotification(me.id, 'createToken', {}); + return { token: accessToken, }; diff --git a/packages/backend/src/types.ts b/packages/backend/src/types.ts index df3cfee171..bf409031c8 100644 --- a/packages/backend/src/types.ts +++ b/packages/backend/src/types.ts @@ -18,6 +18,7 @@ * achievementEarned - 実績を獲得 * exportCompleted - エクスポートが完了 * login - ログイン + * createToken - トークン作成 * app - アプリ通知 * test - テスト通知(サーバー側) */ @@ -36,6 +37,7 @@ export const notificationTypes = [ 'achievementEarned', 'exportCompleted', 'login', + 'createToken', 'app', 'test', ] as const; |