From 9535bbcf8915e8ee9808a426441865e972e4a92d Mon Sep 17 00:00:00 2001 From: Namekuji Date: Sun, 30 Apr 2023 19:45:53 -0400 Subject: [PATCH] do not notify if the target is not following --- .../src/services/note/reaction/create.ts | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/services/note/reaction/create.ts b/packages/backend/src/services/note/reaction/create.ts index 1a3c52eb5..20a724f3d 100644 --- a/packages/backend/src/services/note/reaction/create.ts +++ b/packages/backend/src/services/note/reaction/create.ts @@ -12,6 +12,7 @@ import { Notes, Emojis, Blockings, + Followings, } from "@/models/index.js"; import { IsNull, Not } from "typeorm"; import { perUserReactionsChart } from "@/services/chart/index.js"; @@ -21,6 +22,7 @@ import deleteReaction from "./delete.js"; import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js"; import type { NoteReaction } from "@/models/entities/note-reaction.js"; import { IdentifiableError } from "@/misc/identifiable-error.js"; +import { shouldSilenceInstance } from "@/misc/should-block-instance.js"; export default async ( user: { id: User["id"]; host: User["host"] }, @@ -118,8 +120,25 @@ export default async ( userId: user.id, }); - // リアクションされたユーザーがローカルユーザーなら通知を作成 - if (note.userHost === null) { + // Create notification if the reaction target is a local user. + if ( + note.userHost === null && + // if a local user reacted, or + (Users.isLocalUser(user) || + // if a remote user not in a silenced instance reacted + (Users.isRemoteUser(user) && + // if a remote user is in a silenced instance and the target is a local follower. + !( + (await shouldSilenceInstance(user.host)) && + !(await Followings.exist({ + where: { + followerId: note.userId, + followerHost: IsNull(), + followeeId: user.id, + }, + })) + ))) + ) { createNotification(note.userId, "reaction", { notifierId: user.id, note: note, @@ -143,7 +162,7 @@ export default async ( } }); - //#region 配信 + //#region deliver if (Users.isLocalUser(user) && !note.localOnly) { const content = renderActivity(await renderLike(record, note)); const dm = new DeliverManager(user, content);