do not notify if the target is not following

This commit is contained in:
Namekuji 2023-04-30 19:45:53 -04:00
parent 5338185605
commit 9535bbcf89
No known key found for this signature in database
GPG Key ID: B541BD6E646CABC7
1 changed files with 22 additions and 3 deletions

View File

@ -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);