From 2e52781ddbfa4e9c6c40c7e914b77c32f93b6261 Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Thu, 3 Oct 2024 15:06:04 +0900 Subject: [PATCH] enhance(backend): notify new login (#14673) * wip * Update CHANGELOG.md * wip * fix * Update index.d.ts * Update SigninService.ts * Update MkNotification.vue --- CHANGELOG.md | 2 +- packages/backend/src/models/Notification.ts | 6 +++++- packages/backend/src/server/api/SigninService.ts | 2 +- packages/misskey-js/src/autogen/types.ts | 9 +-------- packages/sw/src/scripts/create-notification.ts | 6 ++++++ 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eef414be9fe9..d4869654f2d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ - Enhance: フォロワーへのメッセージ欄のデザイン改良 ### Server -- +- Enhance: セキュリティ向上のため、ログイン時にメール通知を行うように ## 2024.9.0 diff --git a/packages/backend/src/models/Notification.ts b/packages/backend/src/models/Notification.ts index 6f85f8e82cef..59946e96e5f1 100644 --- a/packages/backend/src/models/Notification.ts +++ b/packages/backend/src/models/Notification.ts @@ -3,12 +3,12 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +import { userExportableEntities } from '@/types.js'; import { MiUser } from './User.js'; import { MiNote } from './Note.js'; import { MiAccessToken } from './AccessToken.js'; import { MiRole } from './Role.js'; import { MiDriveFile } from './DriveFile.js'; -import { userExportableEntities } from '@/types.js'; export type MiNotification = { type: 'note'; @@ -90,6 +90,10 @@ export type MiNotification = { createdAt: string; exportedEntity: typeof userExportableEntities[number]; fileId: MiDriveFile['id']; +} | { + type: 'login'; + id: string; + createdAt: string; } | { type: 'app'; id: string; diff --git a/packages/backend/src/server/api/SigninService.ts b/packages/backend/src/server/api/SigninService.ts index fbac004e8b06..24f0503537e2 100644 --- a/packages/backend/src/server/api/SigninService.ts +++ b/packages/backend/src/server/api/SigninService.ts @@ -5,7 +5,7 @@ import { Inject, Injectable } from '@nestjs/common'; import { DI } from '@/di-symbols.js'; -import type { SigninsRepository, UserProfilesRepository } from '@/models/_.js'; +import type { SigninsRepository } from '@/models/_.js'; import { IdService } from '@/core/IdService.js'; import type { MiLocalUser } from '@/models/User.js'; import { GlobalEventService } from '@/core/GlobalEventService.js'; diff --git a/packages/misskey-js/src/autogen/types.ts b/packages/misskey-js/src/autogen/types.ts index dbeb5daeb694..2e658296559b 100644 --- a/packages/misskey-js/src/autogen/types.ts +++ b/packages/misskey-js/src/autogen/types.ts @@ -4469,14 +4469,7 @@ export type components = { exportedEntity: 'antenna' | 'blocking' | 'clip' | 'customEmoji' | 'favorite' | 'following' | 'muting' | 'note' | 'userList'; /** Format: id */ fileId: string; - }) | { - /** Format: id */ - id: string; - /** Format: date-time */ - createdAt: string; - /** @enum {string} */ - type: 'login'; - } | ({ + }) | ({ /** Format: id */ id: string; /** Format: date-time */ diff --git a/packages/sw/src/scripts/create-notification.ts b/packages/sw/src/scripts/create-notification.ts index 313f934cbc02..7427ae612e3c 100644 --- a/packages/sw/src/scripts/create-notification.ts +++ b/packages/sw/src/scripts/create-notification.ts @@ -216,6 +216,12 @@ async function composeNotification(data: PushNotificationDataMap[keyof PushNotif data, }]; + case 'login': + return [i18n.ts._notification.login, { + badge: iconUrl('login-2'), + data, + }]; + case 'exportCompleted': { const entityName = { antenna: i18n.ts.antennas,