1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-23 04:04:08 +02:00
Files
misskey/packages/backend/src/misc/is-channel-related.ts
おさむのひと 729abbef62 feat: チャンネルミュートの実装 (#14105)
* add channel_muting table and entities

* add channel_muting services

* タイムライン取得処理への組み込み

* misskey-jsの型とインターフェース生成

* Channelスキーマにミュート情報を追加

* フロントエンドの実装

* 条件が逆だったのを修正

* 期限切れミュートを掃除する機能を実装

* TLの抽出条件調節

* 名前の変更と変更不要の差分をロールバック

* 修正漏れ

* isChannelRelatedの条件に誤りがあった

* [wip] テスト追加

* テストの追加と検出した不備の修正

* fix test

* fix CHANGELOG.md

* 通常はFTTにしておく

* 実装忘れ対応

* fix merge

* fix merge

* add channel tl test

* fix CHANGELOG.md

* remove unused import

* fix lint

* fix test

* fix favorite -> favorited

* exclude -> include

* fix CHANGELOG.md

* fix CHANGELOG.md

* maintenance

* fix CHANGELOG.md

* fix

* fix ci

* regenerate

* fix

* Revert "fix"

This reverts commit 699d50c6ec.

* fixed

---------

Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
2025-11-07 08:39:21 +09:00

32 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { MiNote } from '@/models/Note.js';
import { Packed } from '@/misc/json-schema.js';
/**
* {@link note}が{@link channelIds}のチャンネルに関連するかどうかを判定し、関連する場合はtrueを返します。
* 関連するというのは、{@link channelIds}のチャンネルに向けての投稿であるか、またはそのチャンネルの投稿をリノート・引用リノートした投稿であるかを指します。
*
* @param note 確認対象のノート
* @param channelIds 確認対象のチャンネルID一覧
* @param ignoreAuthor trueの場合、ートの所属チャンネルが{@link channelIds}に含まれていても無視しますデフォルトはfalse
*/
export function isChannelRelated(note: MiNote | Packed<'Note'>, channelIds: Set<string>, ignoreAuthor = false): boolean {
// ートの所属チャンネルが確認対象のチャンネルID一覧に含まれている場合
if (!ignoreAuthor && note.channelId && channelIds.has(note.channelId)) {
return true;
}
const renoteChannelId = note.renote?.channelId;
if (renoteChannelId != null && renoteChannelId !== note.channelId && channelIds.has(renoteChannelId)) {
return true;
}
// NOTE: リプライはchannelIdのチェックだけでOKなはずなので見てない(チャンネルのノートにチャンネル外からのリプライまたはその逆はないはずなので)
return false;
}