Sharkey/packages/backend/src/core
taichan 5f43c2faa2
enhance(backend): 通知がミュート・凍結を考慮するようにする (#13412)
* Never return broken notifications #409

Since notifications are stored in Redis, we can't expect relational
integrity: deleting a user will *not* delete notifications that
mention it.

But if we return notifications with missing bits (a `follow` without a
`user`, for example), the frontend will get very confused and throw an
exception while trying to render them.

This change makes sure we never expose those broken notifications. For
uniformity, I've applied the same logic to notes and roles mentioned
in notifications, even if nobody reported breakage in those cases.

Tested by creating a few types of notifications with a `notifierId`,
then deleting their user.

(cherry picked from commit 421f8d49e5)

* Update Changelog

* Update CHANGELOG.md

* enhance: 通知がミュートを考慮するようにする

* enhance: 通知が凍結も考慮するようにする

* fix: notifierIdがない通知が消えてしまう問題

* Add tests (通知がミュートを考慮しているかどうか)

* fix: notifierIdがない通知が消えてしまう問題 (grouped)

* Remove unused import

* Fix: typo

* Revert "enhance: 通知が凍結も考慮するようにする"

This reverts commit b1e57e571dfd9a7d8b2430294473c2053cc3ea33.

* Revert API handling

* Remove unused imports

* enhance: Check if notifierId is valid in NotificationEntityService

* 通知作成時にpackしてnullになったらあとの処理をやめる

* Remove duplication of valid notifier check

* add filter notification is not null

* Revert "Remove duplication of valid notifier check"

This reverts commit 239a6952f717add53d52c3e701e7362eb1987645.

* Improve performance

* Fix packGrouped

* Refactor: 判定部分を共通化

* Fix condition

* use isNotNull

* Update CHANGELOG.md

* filterの改善

* Refactor: DONT REPEAT YOURSELF
Note: GroupedNotificationはNotificationの拡張なのでその例外だけ書けば基本的に共通の処理になり複雑な個別の処理は増えにくいと思われる

* Add groupedNotificationTypes

* Update misskey-js typedef

* Refactor: less sql calls

* refactor

* clean up

* filter notes to mark as read

* packed noteがmapなのでそちらを使う

* if (notesToRead.size > 0)

* if (notes.length === 0) return;

* fix

* Revert "if (notes.length === 0) return;"

This reverts commit 22e2324f9633bddba50769ef838bc5ddb4564c88.

* 🎨

* console.error

* err

* remove try-catch

* 不要なジェネリクスを除去

* Revert  (既読処理をpack内で行うものを元に戻す)

* Clean

* Update packages/backend/src/core/entities/NotificationEntityService.ts

* Update packages/backend/src/core/entities/NotificationEntityService.ts

* Update packages/backend/src/core/entities/NotificationEntityService.ts

* Update packages/backend/src/core/entities/NotificationEntityService.ts

* Update packages/backend/src/core/NotificationService.ts

* Clean

---------

Co-authored-by: dakkar <dakkar@thenautilus.net>
Co-authored-by: kakkokari-gtyih <daisho7308+f@gmail.com>
Co-authored-by: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com>
Co-authored-by: tamaina <tamaina@hotmail.co.jp>
Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
2024-02-28 21:26:26 +09:00
..
activitypub enhance?: DeleteAccountServiceでユーザーを削除する際にuserChangeDeletedStateを発行する (#13382) 2024-02-23 18:15:39 +09:00
chart (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
entities enhance(backend): 通知がミュート・凍結を考慮するようにする (#13412) 2024-02-28 21:26:26 +09:00
AccountMoveService.ts fix: 古いキャッシュを使うのを修正 (#13453) 2024-02-25 12:36:10 +09:00
AccountUpdateService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
AchievementService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
AiService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
AnnouncementService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
AntennaService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
AppLockService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
AvatarDecorationService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
CacheService.ts fix: 古いキャッシュを使うのを修正 (#13453) 2024-02-25 12:36:10 +09:00
CaptchaService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
ChannelFollowingService.ts Fix: チャンネルのフォロー・アンフォローの反映速度を改善 (#12149) 2023-10-27 18:34:02 +09:00
ClipService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
CoreModule.ts enhance: metaをSSR HTMLに埋め込む (#13436) 2024-02-23 10:47:17 +09:00
CreateSystemUserService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
CustomEmojiService.ts admin/emoji/updateの必須項目を減らす 等 (#13449) 2024-02-25 18:06:26 +09:00
DeleteAccountService.ts enhance?: DeleteAccountServiceでユーザーを削除する際にuserChangeDeletedStateを発行する (#13382) 2024-02-23 18:15:39 +09:00
DownloadService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
DriveService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
EmailService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
FanoutTimelineEndpointService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
FanoutTimelineService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
FeaturedService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
FederatedInstanceService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
FetchInstanceMetadataService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
FileInfoService.ts fix: Bump sharp to 0.33.2 (#13391) 2024-02-21 14:42:37 +09:00
GlobalEventService.ts fix: 古いキャッシュを使うのを修正 (#13453) 2024-02-25 12:36:10 +09:00
HashtagService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
HttpRequestService.ts Merge pull request from GHSA-qqrm-9grj-6v32 2024-02-17 12:41:19 +09:00
IdService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
ImageProcessingService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
InstanceActorService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
InternalStorageService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
LoggerService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
MetaService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
MfmService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
ModerationLogService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
NoteCreateService.ts refactor(backend): Array.prototype.filterでの非null確認ではisNotNull関数を使うように (#13442) 2024-02-23 14:12:57 +09:00
NoteDeleteService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
NotePiningService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
NoteReadService.ts refactor: Refactor NoteReadService.read (#13429) 2024-02-22 21:10:28 +09:00
NotificationService.ts enhance(backend): 通知がミュート・凍結を考慮するようにする (#13412) 2024-02-28 21:26:26 +09:00
PollService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
ProxyAccountService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
PushNotificationService.ts fix: プッシュ通知の変更が1時間ほど反映されない問題を修正 (#13407) 2024-02-23 17:19:08 +09:00
QueryService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
QueueModule.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
QueueService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
ReactionService.ts refactor(backend): ReactionService.prototype.convertLegacyReactions (#13375) 2024-02-21 14:31:50 +09:00
RegistryApiService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
RelayService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
RemoteLoggerService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
RemoteUserResolveService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
ReversiService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
RoleService.ts Enhance: コンディショナルロールの条件に「マニュアルロールへのアサイン」を追加 (#13463) 2024-02-27 18:45:46 +09:00
S3Service.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
SearchService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
SignupService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
UserAuthService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
UserBlockingService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
UserFollowingService.ts fix: 古いキャッシュを使うのを修正 (#13453) 2024-02-25 12:36:10 +09:00
UserKeypairService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
UserListService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
UserMutingService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
UserService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
UserSuspendService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
UtilityService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
VideoProcessingService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
WebAuthnService.ts refactor(backend): remove/replace deprecated type deps (#13252) 2024-02-16 20:09:07 +09:00
WebfingerService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00
WebhookService.ts (re) update SPDX-FileCopyrightText 2024-02-13 15:59:27 +00:00