forked from mirrors/misskey
Merge commit from fork
* Tighten security in `HashtagChannel` * Add isNoteVisibleForMe in stream channel Co-Authored-By: Julia Johannesen <julia@insertdomain.name> * Tighten note visibility checks in WebSocket (No.1) * refactor * Fix main channel Co-Authored-By: Julia Johannesen <julia@insertdomain.name> * fix typo * fix missing lockdown (requireSigninToViewContents) checks * fix(backend): streamingでのロックダウン挙動修正 * fix: 引用リノートを無条件で隠していた問題を修正 * fix: 引用リノートを単純にリノート場合に内容が見えることがある問題を修正 * refac * fix * fix * fix * Update docs --------- Co-authored-by: Julia Johannesen <julia@insertdomain.name> Co-authored-by: KanariKanaru <93921745+kanarikanaru@users.noreply.github.com>
This commit is contained in:
@@ -259,7 +259,7 @@ export class QueryService {
|
|||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public generateVisibilityQuery(q: SelectQueryBuilder<any>, me?: { id: MiUser['id'] } | null): void {
|
public generateVisibilityQuery(q: SelectQueryBuilder<any>, me?: { id: MiUser['id'] } | null): void {
|
||||||
// This code must always be synchronized with the checks in Notes.isVisibleForMe.
|
// This code must always be synchronized with the checks in NoteEntityService.isVisibleForMe and Stream abstract class Channel.isNoteVisibleForMe.
|
||||||
if (me == null) {
|
if (me == null) {
|
||||||
q.andWhere(new Brackets(qb => {
|
q.andWhere(new Brackets(qb => {
|
||||||
qb
|
qb
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import { DebounceLoader } from '@/misc/loader.js';
|
|||||||
import { IdService } from '@/core/IdService.js';
|
import { IdService } from '@/core/IdService.js';
|
||||||
import { shouldHideNoteByTime } from '@/misc/should-hide-note-by-time.js';
|
import { shouldHideNoteByTime } from '@/misc/should-hide-note-by-time.js';
|
||||||
import { ReactionsBufferingService } from '@/core/ReactionsBufferingService.js';
|
import { ReactionsBufferingService } from '@/core/ReactionsBufferingService.js';
|
||||||
|
import { CacheService } from '@/core/CacheService.js';
|
||||||
import type { OnModuleInit } from '@nestjs/common';
|
import type { OnModuleInit } from '@nestjs/common';
|
||||||
import type { CustomEmojiService } from '../CustomEmojiService.js';
|
import type { CustomEmojiService } from '../CustomEmojiService.js';
|
||||||
import type { ReactionService } from '../ReactionService.js';
|
import type { ReactionService } from '../ReactionService.js';
|
||||||
@@ -66,6 +67,7 @@ export class NoteEntityService implements OnModuleInit {
|
|||||||
private reactionService: ReactionService;
|
private reactionService: ReactionService;
|
||||||
private reactionsBufferingService: ReactionsBufferingService;
|
private reactionsBufferingService: ReactionsBufferingService;
|
||||||
private idService: IdService;
|
private idService: IdService;
|
||||||
|
private cacheService: CacheService;
|
||||||
private noteLoader = new DebounceLoader(this.findNoteOrFail);
|
private noteLoader = new DebounceLoader(this.findNoteOrFail);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -101,6 +103,7 @@ export class NoteEntityService implements OnModuleInit {
|
|||||||
//private reactionService: ReactionService,
|
//private reactionService: ReactionService,
|
||||||
//private reactionsBufferingService: ReactionsBufferingService,
|
//private reactionsBufferingService: ReactionsBufferingService,
|
||||||
//private idService: IdService,
|
//private idService: IdService,
|
||||||
|
//private cacheService: CacheService,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,6 +114,7 @@ export class NoteEntityService implements OnModuleInit {
|
|||||||
this.reactionService = this.moduleRef.get('ReactionService');
|
this.reactionService = this.moduleRef.get('ReactionService');
|
||||||
this.reactionsBufferingService = this.moduleRef.get('ReactionsBufferingService');
|
this.reactionsBufferingService = this.moduleRef.get('ReactionsBufferingService');
|
||||||
this.idService = this.moduleRef.get('IdService');
|
this.idService = this.moduleRef.get('IdService');
|
||||||
|
this.cacheService = this.moduleRef.get('CacheService');
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
@@ -125,75 +129,65 @@ export class NoteEntityService implements OnModuleInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
private async hideNote(packedNote: Packed<'Note'>, meId: MiUser['id'] | null): Promise<void> {
|
public async shouldHideNote(packedNote: Packed<'Note'>, meId: MiUser['id'] | null): Promise<boolean> {
|
||||||
if (meId === packedNote.userId) return;
|
if (meId === packedNote.userId) return false;
|
||||||
|
|
||||||
// TODO: isVisibleForMe を使うようにしても良さそう(型違うけど)
|
// TODO: isVisibleForMe を使うようにしても良さそう(型違うけど)
|
||||||
let hide = false;
|
|
||||||
|
|
||||||
if (packedNote.user.requireSigninToViewContents && meId == null) {
|
if (packedNote.user.requireSigninToViewContents && meId == null) {
|
||||||
hide = true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hide) {
|
const hiddenBefore = packedNote.user.makeNotesHiddenBefore;
|
||||||
const hiddenBefore = packedNote.user.makeNotesHiddenBefore;
|
if (shouldHideNoteByTime(hiddenBefore, packedNote.createdAt)) {
|
||||||
if (shouldHideNoteByTime(hiddenBefore, packedNote.createdAt)) {
|
return true;
|
||||||
hide = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// visibility が specified かつ自分が指定されていなかったら非表示
|
// visibility が specified かつ自分が指定されていなかったら非表示
|
||||||
if (!hide) {
|
if (packedNote.visibility === 'specified') {
|
||||||
if (packedNote.visibility === 'specified') {
|
if (meId == null) {
|
||||||
if (meId == null) {
|
return true;
|
||||||
hide = true;
|
} else {
|
||||||
} else {
|
// 指定されているかどうか
|
||||||
// 指定されているかどうか
|
const specified = packedNote.visibleUserIds!.some(id => meId === id);
|
||||||
const specified = packedNote.visibleUserIds!.some(id => meId === id);
|
|
||||||
|
|
||||||
if (!specified) {
|
if (!specified) {
|
||||||
hide = true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// visibility が followers かつ自分が投稿者のフォロワーでなかったら非表示
|
// visibility が followers かつ自分が投稿者のフォロワーでなかったら非表示
|
||||||
if (!hide) {
|
if (packedNote.visibility === 'followers') {
|
||||||
if (packedNote.visibility === 'followers') {
|
if (meId == null) {
|
||||||
if (meId == null) {
|
return true;
|
||||||
hide = true;
|
} else if (packedNote.reply && (meId === packedNote.reply.userId)) {
|
||||||
} else if (packedNote.reply && (meId === packedNote.reply.userId)) {
|
// 自分の投稿に対するリプライ
|
||||||
// 自分の投稿に対するリプライ
|
return false;
|
||||||
hide = false;
|
} else if (packedNote.mentions && packedNote.mentions.some(id => meId === id)) {
|
||||||
} else if (packedNote.mentions && packedNote.mentions.some(id => meId === id)) {
|
// 自分へのメンション
|
||||||
// 自分へのメンション
|
return false;
|
||||||
hide = false;
|
} else {
|
||||||
} else {
|
// フォロワーかどうか
|
||||||
// フォロワーかどうか
|
const followings = await this.cacheService.userFollowingsCache.fetch(meId);
|
||||||
// TODO: 当関数呼び出しごとにクエリが走るのは重そうだからなんとかする
|
if (!Object.hasOwn(followings, packedNote.userId)) {
|
||||||
const isFollowing = await this.followingsRepository.exists({
|
return true;
|
||||||
where: {
|
|
||||||
followeeId: packedNote.userId,
|
|
||||||
followerId: meId,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
hide = !isFollowing;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hide) {
|
return false;
|
||||||
packedNote.visibleUserIds = undefined;
|
}
|
||||||
packedNote.fileIds = [];
|
|
||||||
packedNote.files = [];
|
@bindThis
|
||||||
packedNote.text = null;
|
public hideNote(packedNote: Packed<'Note'>): void {
|
||||||
packedNote.poll = undefined;
|
packedNote.visibleUserIds = undefined;
|
||||||
packedNote.cw = null;
|
packedNote.fileIds = [];
|
||||||
packedNote.isHidden = true;
|
packedNote.files = [];
|
||||||
// TODO: hiddenReason みたいなのを提供しても良さそう
|
packedNote.text = null;
|
||||||
}
|
packedNote.poll = undefined;
|
||||||
|
packedNote.cw = null;
|
||||||
|
packedNote.isHidden = true;
|
||||||
|
// TODO: hiddenReason みたいなのを提供しても良さそう
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
@@ -278,7 +272,7 @@ export class NoteEntityService implements OnModuleInit {
|
|||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async isVisibleForMe(note: MiNote, meId: MiUser['id'] | null): Promise<boolean> {
|
public async isVisibleForMe(note: MiNote, meId: MiUser['id'] | null): Promise<boolean> {
|
||||||
// This code must always be synchronized with the checks in generateVisibilityQuery.
|
// This code must always be synchronized with the checks in QueryService.generateVisibilityQuery.
|
||||||
// visibility が specified かつ自分が指定されていなかったら非表示
|
// visibility が specified かつ自分が指定されていなかったら非表示
|
||||||
if (note.visibility === 'specified') {
|
if (note.visibility === 'specified') {
|
||||||
if (meId == null) {
|
if (meId == null) {
|
||||||
@@ -468,8 +462,8 @@ export class NoteEntityService implements OnModuleInit {
|
|||||||
|
|
||||||
this.treatVisibility(packed);
|
this.treatVisibility(packed);
|
||||||
|
|
||||||
if (!opts.skipHide) {
|
if (!opts.skipHide && await this.shouldHideNote(packed, meId)) {
|
||||||
await this.hideNote(packed, meId);
|
this.hideNote(packed);
|
||||||
}
|
}
|
||||||
|
|
||||||
return packed;
|
return packed;
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ import { ChatUserChannel } from './api/stream/channels/chat-user.js';
|
|||||||
import { ChatRoomChannel } from './api/stream/channels/chat-room.js';
|
import { ChatRoomChannel } from './api/stream/channels/chat-room.js';
|
||||||
import { ReversiChannel } from './api/stream/channels/reversi.js';
|
import { ReversiChannel } from './api/stream/channels/reversi.js';
|
||||||
import { ReversiGameChannel } from './api/stream/channels/reversi-game.js';
|
import { ReversiGameChannel } from './api/stream/channels/reversi-game.js';
|
||||||
|
import { NoteStreamingHidingService } from './api/stream/NoteStreamingHidingService.js';
|
||||||
import { SigninWithPasskeyApiService } from './api/SigninWithPasskeyApiService.js';
|
import { SigninWithPasskeyApiService } from './api/SigninWithPasskeyApiService.js';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
@@ -98,6 +99,7 @@ import { SigninWithPasskeyApiService } from './api/SigninWithPasskeyApiService.j
|
|||||||
QueueStatsChannel,
|
QueueStatsChannel,
|
||||||
ServerStatsChannel,
|
ServerStatsChannel,
|
||||||
UserListChannel,
|
UserListChannel,
|
||||||
|
NoteStreamingHidingService,
|
||||||
OpenApiServerService,
|
OpenApiServerService,
|
||||||
OAuth2ProviderService,
|
OAuth2ProviderService,
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -0,0 +1,132 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { bindThis } from '@/decorators.js';
|
||||||
|
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
|
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
|
||||||
|
import type { Packed } from '@/misc/json-schema.js';
|
||||||
|
import type { MiUser } from '@/models/User.js';
|
||||||
|
|
||||||
|
type HiddenLayer = 'note' | 'renote' | 'renoteRenote';
|
||||||
|
|
||||||
|
type LockdownCheckResult =
|
||||||
|
| { shouldSkip: true }
|
||||||
|
| { shouldSkip: false; hiddenLayers: Set<HiddenLayer> };
|
||||||
|
|
||||||
|
/** Streamにおいて、ノートを隠す(hideNote)を適用するためのService */
|
||||||
|
@Injectable()
|
||||||
|
export class NoteStreamingHidingService {
|
||||||
|
constructor(
|
||||||
|
private noteEntityService: NoteEntityService,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ノートの可視性を判定する
|
||||||
|
*
|
||||||
|
* @param note - 判定対象のノート
|
||||||
|
* @param meId - 閲覧者のユーザーID(未ログインの場合はnull)
|
||||||
|
* @returns shouldSkip: true の場合はノートを流さない、false の場合は hiddenLayers に基づいて隠す
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public async shouldHide(
|
||||||
|
note: Packed<'Note'>,
|
||||||
|
meId: MiUser['id'] | null,
|
||||||
|
): Promise<LockdownCheckResult> {
|
||||||
|
const hiddenLayers = new Set<HiddenLayer>();
|
||||||
|
|
||||||
|
// 1階層目: note自体
|
||||||
|
const shouldHideThisNote = await this.noteEntityService.shouldHideNote(note, meId);
|
||||||
|
if (shouldHideThisNote) {
|
||||||
|
if (isRenotePacked(note) && isQuotePacked(note)) {
|
||||||
|
// 引用リノートの場合、内容を隠して流す
|
||||||
|
hiddenLayers.add('note');
|
||||||
|
} else if (isRenotePacked(note)) {
|
||||||
|
// 純粋リノートの場合、流さない
|
||||||
|
return { shouldSkip: true };
|
||||||
|
} else {
|
||||||
|
// 通常ノートの場合、内容を隠して流す
|
||||||
|
hiddenLayers.add('note');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2階層目: note.renote
|
||||||
|
if (isRenotePacked(note) && note.renote) {
|
||||||
|
const shouldHideRenote = await this.noteEntityService.shouldHideNote(note.renote, meId);
|
||||||
|
if (shouldHideRenote) {
|
||||||
|
if (isQuotePacked(note)) {
|
||||||
|
// noteが引用リノートの場合、renote部分だけ隠す
|
||||||
|
hiddenLayers.add('renote');
|
||||||
|
} else {
|
||||||
|
// noteが純粋リノートの場合、流さない
|
||||||
|
return { shouldSkip: true };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3階層目: note.renote.renote
|
||||||
|
if (isRenotePacked(note) && note.renote &&
|
||||||
|
isRenotePacked(note.renote) && note.renote.renote) {
|
||||||
|
const shouldHideRenoteRenote = await this.noteEntityService.shouldHideNote(note.renote.renote, meId);
|
||||||
|
if (shouldHideRenoteRenote) {
|
||||||
|
if (isQuotePacked(note.renote)) {
|
||||||
|
// note.renoteが引用リノートの場合、renote.renote部分だけ隠す
|
||||||
|
hiddenLayers.add('renoteRenote');
|
||||||
|
} else {
|
||||||
|
// note.renoteが純粋リノートの場合、note.renoteの意味がなくなるので流さない
|
||||||
|
return { shouldSkip: true };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { shouldSkip: false, hiddenLayers };
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hiddenLayersに基づいてノートの内容を隠す。
|
||||||
|
*
|
||||||
|
* この処理は渡された `note` を直接変更します。
|
||||||
|
*
|
||||||
|
* @param note - 処理対象のノート
|
||||||
|
* @param hiddenLayers - 隠す階層のセット
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public applyHiding(
|
||||||
|
note: Packed<'Note'>,
|
||||||
|
hiddenLayers: Set<HiddenLayer>,
|
||||||
|
): void {
|
||||||
|
if (hiddenLayers.has('note')) {
|
||||||
|
this.noteEntityService.hideNote(note);
|
||||||
|
}
|
||||||
|
if (hiddenLayers.has('renote') && note.renote) {
|
||||||
|
this.noteEntityService.hideNote(note.renote);
|
||||||
|
}
|
||||||
|
if (hiddenLayers.has('renoteRenote') && note.renote && note.renote.renote) {
|
||||||
|
this.noteEntityService.hideNote(note.renote.renote);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ストリーミング配信用にノートを隠す(あるいはそもそも送信しない)の判定及び処理を行う。
|
||||||
|
*
|
||||||
|
* この処理は渡された `note` を直接変更します。
|
||||||
|
*
|
||||||
|
* @param note - 処理対象のノート(必要に応じて内容が隠される)
|
||||||
|
* @param meId - 閲覧者のユーザーID(未ログインの場合はnull)
|
||||||
|
* @returns shouldSkip: true の場合はノートを流さない
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public async processHiding(
|
||||||
|
note: Packed<'Note'>,
|
||||||
|
meId: MiUser['id'] | null,
|
||||||
|
): Promise<{ shouldSkip: boolean }> {
|
||||||
|
const result = await this.shouldHide(note, meId);
|
||||||
|
if (result.shouldSkip) {
|
||||||
|
return { shouldSkip: true };
|
||||||
|
}
|
||||||
|
this.applyHiding(note, result.hiddenLayers);
|
||||||
|
return { shouldSkip: false };
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -64,6 +64,43 @@ export default abstract class Channel {
|
|||||||
return this.connection.subscriber;
|
return this.connection.subscriber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected isNoteVisibleForMe(note: Packed<'Note'>): boolean {
|
||||||
|
// This code must always be synchronized with the checks in QueryService.generateVisibilityQuery.
|
||||||
|
const meId = this.connection.user?.id ?? null;
|
||||||
|
|
||||||
|
// visibility が specified かつ自分が指定されていなかったら非表示
|
||||||
|
if (note.visibility === 'specified') {
|
||||||
|
if (meId == null) {
|
||||||
|
return false;
|
||||||
|
} else if (meId === note.userId) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
// 指定されているかどうか
|
||||||
|
return note.visibleUserIds?.some(id => meId === id) ?? false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// visibility が followers かつ自分が投稿者のフォロワーでなかったら非表示
|
||||||
|
if (note.visibility === 'followers') {
|
||||||
|
if (meId == null) {
|
||||||
|
return false;
|
||||||
|
} else if (meId === note.userId) {
|
||||||
|
return true;
|
||||||
|
} else if (note.reply && (meId === note.reply.userId)) {
|
||||||
|
// 自分の投稿に対するリプライ
|
||||||
|
return true;
|
||||||
|
} else if (note.mentions && note.mentions.some(id => meId === id)) {
|
||||||
|
// 自分へのメンション
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
// フォロワーかどうか
|
||||||
|
return Object.hasOwn(this.following, note.userId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ミュートとブロックされてるを処理する
|
* ミュートとブロックされてるを処理する
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,7 +5,9 @@
|
|||||||
|
|
||||||
import { Inject, Injectable, Scope } from '@nestjs/common';
|
import { Inject, Injectable, Scope } from '@nestjs/common';
|
||||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
|
import { NoteStreamingHidingService } from '../NoteStreamingHidingService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
|
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
|
||||||
import type { GlobalEvents } from '@/core/GlobalEventService.js';
|
import type { GlobalEvents } from '@/core/GlobalEventService.js';
|
||||||
import type { JsonObject } from '@/misc/json-value.js';
|
import type { JsonObject } from '@/misc/json-value.js';
|
||||||
import Channel, { type ChannelRequest } from '../channel.js';
|
import Channel, { type ChannelRequest } from '../channel.js';
|
||||||
@@ -24,6 +26,7 @@ export class AntennaChannel extends Channel {
|
|||||||
request: ChannelRequest,
|
request: ChannelRequest,
|
||||||
|
|
||||||
private noteEntityService: NoteEntityService,
|
private noteEntityService: NoteEntityService,
|
||||||
|
private noteStreamingHidingService: NoteStreamingHidingService,
|
||||||
) {
|
) {
|
||||||
super(request);
|
super(request);
|
||||||
//this.onEvent = this.onEvent.bind(this);
|
//this.onEvent = this.onEvent.bind(this);
|
||||||
@@ -43,8 +46,21 @@ export class AntennaChannel extends Channel {
|
|||||||
if (data.type === 'note') {
|
if (data.type === 'note') {
|
||||||
const note = await this.noteEntityService.pack(data.body.id, this.user, { detail: true });
|
const note = await this.noteEntityService.pack(data.body.id, this.user, { detail: true });
|
||||||
|
|
||||||
|
if (!this.isNoteVisibleForMe(note)) return;
|
||||||
if (this.isNoteMutedOrBlocked(note)) return;
|
if (this.isNoteMutedOrBlocked(note)) return;
|
||||||
|
|
||||||
|
const { shouldSkip } = await this.noteStreamingHidingService.processHiding(note, this.user?.id ?? null);
|
||||||
|
if (shouldSkip) return;
|
||||||
|
|
||||||
|
if (this.user) {
|
||||||
|
if (isRenotePacked(note) && !isQuotePacked(note)) {
|
||||||
|
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
||||||
|
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
||||||
|
note.renote.myReaction = myRenoteReaction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.send('note', note);
|
this.send('note', note);
|
||||||
} else {
|
} else {
|
||||||
this.send(data.type, data.body);
|
this.send(data.type, data.body);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
import { Inject, Injectable, Scope } from '@nestjs/common';
|
import { Inject, Injectable, Scope } from '@nestjs/common';
|
||||||
import type { Packed } from '@/misc/json-schema.js';
|
import type { Packed } from '@/misc/json-schema.js';
|
||||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
|
import { NoteStreamingHidingService } from '../NoteStreamingHidingService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
|
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
|
||||||
import { isInstanceMuted } from '@/misc/is-instance-muted.js';
|
import { isInstanceMuted } from '@/misc/is-instance-muted.js';
|
||||||
@@ -26,6 +27,7 @@ export class ChannelChannel extends Channel {
|
|||||||
request: ChannelRequest,
|
request: ChannelRequest,
|
||||||
|
|
||||||
private noteEntityService: NoteEntityService,
|
private noteEntityService: NoteEntityService,
|
||||||
|
private noteStreamingHidingService: NoteStreamingHidingService,
|
||||||
) {
|
) {
|
||||||
super(request);
|
super(request);
|
||||||
//this.onNote = this.onNote.bind(this);
|
//this.onNote = this.onNote.bind(this);
|
||||||
@@ -48,12 +50,18 @@ export class ChannelChannel extends Channel {
|
|||||||
if (note.renote && note.renote.user.requireSigninToViewContents && this.user == null) return;
|
if (note.renote && note.renote.user.requireSigninToViewContents && this.user == null) return;
|
||||||
if (note.reply && note.reply.user.requireSigninToViewContents && this.user == null) return;
|
if (note.reply && note.reply.user.requireSigninToViewContents && this.user == null) return;
|
||||||
|
|
||||||
|
if (!this.isNoteVisibleForMe(note)) return;
|
||||||
if (this.isNoteMutedOrBlocked(note)) return;
|
if (this.isNoteMutedOrBlocked(note)) return;
|
||||||
|
|
||||||
if (this.user && isRenotePacked(note) && !isQuotePacked(note)) {
|
const { shouldSkip } = await this.noteStreamingHidingService.processHiding(note, this.user?.id ?? null);
|
||||||
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
if (shouldSkip) return;
|
||||||
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
|
||||||
note.renote.myReaction = myRenoteReaction;
|
if (this.user) {
|
||||||
|
if (isRenotePacked(note) && !isQuotePacked(note)) {
|
||||||
|
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
||||||
|
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
||||||
|
note.renote.myReaction = myRenoteReaction;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { Inject, Injectable, Scope } from '@nestjs/common';
|
|||||||
import type { Packed } from '@/misc/json-schema.js';
|
import type { Packed } from '@/misc/json-schema.js';
|
||||||
import { MetaService } from '@/core/MetaService.js';
|
import { MetaService } from '@/core/MetaService.js';
|
||||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
|
import { NoteStreamingHidingService } from '../NoteStreamingHidingService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { RoleService } from '@/core/RoleService.js';
|
import { RoleService } from '@/core/RoleService.js';
|
||||||
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
|
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
|
||||||
@@ -29,6 +30,7 @@ export class GlobalTimelineChannel extends Channel {
|
|||||||
private metaService: MetaService,
|
private metaService: MetaService,
|
||||||
private roleService: RoleService,
|
private roleService: RoleService,
|
||||||
private noteEntityService: NoteEntityService,
|
private noteEntityService: NoteEntityService,
|
||||||
|
private noteStreamingHidingService: NoteStreamingHidingService,
|
||||||
) {
|
) {
|
||||||
super(request);
|
super(request);
|
||||||
//this.onNote = this.onNote.bind(this);
|
//this.onNote = this.onNote.bind(this);
|
||||||
@@ -60,10 +62,15 @@ export class GlobalTimelineChannel extends Channel {
|
|||||||
|
|
||||||
if (this.isNoteMutedOrBlocked(note)) return;
|
if (this.isNoteMutedOrBlocked(note)) return;
|
||||||
|
|
||||||
if (this.user && isRenotePacked(note) && !isQuotePacked(note)) {
|
const { shouldSkip } = await this.noteStreamingHidingService.processHiding(note, this.user?.id ?? null);
|
||||||
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
if (shouldSkip) return;
|
||||||
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
|
||||||
note.renote.myReaction = myRenoteReaction;
|
if (this.user) {
|
||||||
|
if (isRenotePacked(note) && !isQuotePacked(note)) {
|
||||||
|
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
||||||
|
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
||||||
|
note.renote.myReaction = myRenoteReaction;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ import { Inject, Injectable, Scope } from '@nestjs/common';
|
|||||||
import { normalizeForSearch } from '@/misc/normalize-for-search.js';
|
import { normalizeForSearch } from '@/misc/normalize-for-search.js';
|
||||||
import type { Packed } from '@/misc/json-schema.js';
|
import type { Packed } from '@/misc/json-schema.js';
|
||||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
|
import { NoteStreamingHidingService } from '../NoteStreamingHidingService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
|
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
|
||||||
import type { JsonObject } from '@/misc/json-value.js';
|
import type { JsonObject } from '@/misc/json-value.js';
|
||||||
import Channel, { type ChannelRequest } from '../channel.js';
|
import Channel, { type ChannelRequest } from '../channel.js';
|
||||||
import { REQUEST } from '@nestjs/core';
|
import { REQUEST } from '@nestjs/core';
|
||||||
|
|
||||||
@Injectable({ scope: Scope.TRANSIENT })
|
@Injectable({ scope: Scope.TRANSIENT })
|
||||||
export class HashtagChannel extends Channel {
|
export class HashtagChannel extends Channel {
|
||||||
public readonly chName = 'hashtag';
|
public readonly chName = 'hashtag';
|
||||||
@@ -25,6 +25,7 @@ export class HashtagChannel extends Channel {
|
|||||||
request: ChannelRequest,
|
request: ChannelRequest,
|
||||||
|
|
||||||
private noteEntityService: NoteEntityService,
|
private noteEntityService: NoteEntityService,
|
||||||
|
private noteStreamingHidingService: NoteStreamingHidingService,
|
||||||
) {
|
) {
|
||||||
super(request);
|
super(request);
|
||||||
//this.onNote = this.onNote.bind(this);
|
//this.onNote = this.onNote.bind(this);
|
||||||
@@ -33,7 +34,11 @@ export class HashtagChannel extends Channel {
|
|||||||
@bindThis
|
@bindThis
|
||||||
public async init(params: JsonObject) {
|
public async init(params: JsonObject) {
|
||||||
if (!Array.isArray(params.q)) return;
|
if (!Array.isArray(params.q)) return;
|
||||||
if (!params.q.every(x => Array.isArray(x) && x.every(y => typeof y === 'string'))) return;
|
if (!params.q.every((x): x is string[] => (
|
||||||
|
Array.isArray(x) &&
|
||||||
|
x.length >= 1 &&
|
||||||
|
x.every(y => typeof y === 'string')
|
||||||
|
))) return;
|
||||||
this.q = params.q;
|
this.q = params.q;
|
||||||
|
|
||||||
// Subscribe stream
|
// Subscribe stream
|
||||||
@@ -46,12 +51,21 @@ export class HashtagChannel extends Channel {
|
|||||||
const matched = this.q.some(tags => tags.every(tag => noteTags.includes(normalizeForSearch(tag))));
|
const matched = this.q.some(tags => tags.every(tag => noteTags.includes(normalizeForSearch(tag))));
|
||||||
if (!matched) return;
|
if (!matched) return;
|
||||||
|
|
||||||
|
if (!this.isNoteVisibleForMe(note)) return;
|
||||||
|
if (note.user.requireSigninToViewContents && this.user == null) return;
|
||||||
|
if (note.renote && note.renote.user.requireSigninToViewContents && this.user == null) return;
|
||||||
|
if (note.reply && note.reply.user.requireSigninToViewContents && this.user == null) return;
|
||||||
if (this.isNoteMutedOrBlocked(note)) return;
|
if (this.isNoteMutedOrBlocked(note)) return;
|
||||||
|
|
||||||
if (this.user && isRenotePacked(note) && !isQuotePacked(note)) {
|
const { shouldSkip } = await this.noteStreamingHidingService.processHiding(note, this.user?.id ?? null);
|
||||||
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
if (shouldSkip) return;
|
||||||
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
|
||||||
note.renote.myReaction = myRenoteReaction;
|
if (this.user) {
|
||||||
|
if (isRenotePacked(note) && !isQuotePacked(note)) {
|
||||||
|
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
||||||
|
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
||||||
|
note.renote.myReaction = myRenoteReaction;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
import { Inject, Injectable, Scope } from '@nestjs/common';
|
import { Inject, Injectable, Scope } from '@nestjs/common';
|
||||||
import type { Packed } from '@/misc/json-schema.js';
|
import type { Packed } from '@/misc/json-schema.js';
|
||||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
|
import { NoteStreamingHidingService } from '../NoteStreamingHidingService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
|
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
|
||||||
import type { JsonObject } from '@/misc/json-value.js';
|
import type { JsonObject } from '@/misc/json-value.js';
|
||||||
@@ -26,6 +27,7 @@ export class HomeTimelineChannel extends Channel {
|
|||||||
request: ChannelRequest,
|
request: ChannelRequest,
|
||||||
|
|
||||||
private noteEntityService: NoteEntityService,
|
private noteEntityService: NoteEntityService,
|
||||||
|
private noteStreamingHidingService: NoteStreamingHidingService,
|
||||||
) {
|
) {
|
||||||
super(request);
|
super(request);
|
||||||
//this.onNote = this.onNote.bind(this);
|
//this.onNote = this.onNote.bind(this);
|
||||||
@@ -55,11 +57,7 @@ export class HomeTimelineChannel extends Channel {
|
|||||||
if (!isMe && !Object.hasOwn(this.following, note.userId)) return;
|
if (!isMe && !Object.hasOwn(this.following, note.userId)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (note.visibility === 'followers') {
|
if (!this.isNoteVisibleForMe(note)) return;
|
||||||
if (!isMe && !Object.hasOwn(this.following, note.userId)) return;
|
|
||||||
} else if (note.visibility === 'specified') {
|
|
||||||
if (!isMe && !note.visibleUserIds!.includes(this.user!.id)) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (note.reply) {
|
if (note.reply) {
|
||||||
const reply = note.reply;
|
const reply = note.reply;
|
||||||
@@ -84,10 +82,15 @@ export class HomeTimelineChannel extends Channel {
|
|||||||
|
|
||||||
if (this.isNoteMutedOrBlocked(note)) return;
|
if (this.isNoteMutedOrBlocked(note)) return;
|
||||||
|
|
||||||
if (this.user && isRenotePacked(note) && !isQuotePacked(note)) {
|
const { shouldSkip } = await this.noteStreamingHidingService.processHiding(note, this.user?.id ?? null);
|
||||||
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
if (shouldSkip) return;
|
||||||
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
|
||||||
note.renote.myReaction = myRenoteReaction;
|
if (this.user) {
|
||||||
|
if (isRenotePacked(note) && !isQuotePacked(note)) {
|
||||||
|
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
||||||
|
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
||||||
|
note.renote.myReaction = myRenoteReaction;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { Inject, Injectable, Scope } from '@nestjs/common';
|
|||||||
import type { Packed } from '@/misc/json-schema.js';
|
import type { Packed } from '@/misc/json-schema.js';
|
||||||
import { MetaService } from '@/core/MetaService.js';
|
import { MetaService } from '@/core/MetaService.js';
|
||||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
|
import { NoteStreamingHidingService } from '../NoteStreamingHidingService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { RoleService } from '@/core/RoleService.js';
|
import { RoleService } from '@/core/RoleService.js';
|
||||||
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
|
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
|
||||||
@@ -31,6 +32,7 @@ export class HybridTimelineChannel extends Channel {
|
|||||||
private metaService: MetaService,
|
private metaService: MetaService,
|
||||||
private roleService: RoleService,
|
private roleService: RoleService,
|
||||||
private noteEntityService: NoteEntityService,
|
private noteEntityService: NoteEntityService,
|
||||||
|
private noteStreamingHidingService: NoteStreamingHidingService,
|
||||||
) {
|
) {
|
||||||
super(request);
|
super(request);
|
||||||
//this.onNote = this.onNote.bind(this);
|
//this.onNote = this.onNote.bind(this);
|
||||||
@@ -75,12 +77,7 @@ export class HybridTimelineChannel extends Channel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (note.visibility === 'followers') {
|
if (!this.isNoteVisibleForMe(note)) return;
|
||||||
if (!isMe && !Object.hasOwn(this.following, note.userId)) return;
|
|
||||||
} else if (note.visibility === 'specified') {
|
|
||||||
if (!isMe && !note.visibleUserIds!.includes(this.user!.id)) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.isNoteMutedOrBlocked(note)) return;
|
if (this.isNoteMutedOrBlocked(note)) return;
|
||||||
|
|
||||||
if (note.reply) {
|
if (note.reply) {
|
||||||
@@ -104,10 +101,15 @@ export class HybridTimelineChannel extends Channel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.user && note.renoteId && !note.text) {
|
const { shouldSkip } = await this.noteStreamingHidingService.processHiding(note, this.user?.id ?? null);
|
||||||
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
if (shouldSkip) return;
|
||||||
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
|
||||||
note.renote.myReaction = myRenoteReaction;
|
if (this.user) {
|
||||||
|
if (isRenotePacked(note) && !isQuotePacked(note)) {
|
||||||
|
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
||||||
|
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
||||||
|
note.renote.myReaction = myRenoteReaction;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { Inject, Injectable, Scope } from '@nestjs/common';
|
|||||||
import type { Packed } from '@/misc/json-schema.js';
|
import type { Packed } from '@/misc/json-schema.js';
|
||||||
import { MetaService } from '@/core/MetaService.js';
|
import { MetaService } from '@/core/MetaService.js';
|
||||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
|
import { NoteStreamingHidingService } from '../NoteStreamingHidingService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { RoleService } from '@/core/RoleService.js';
|
import { RoleService } from '@/core/RoleService.js';
|
||||||
import { isQuotePacked, isRenotePacked } from '@/misc/is-renote.js';
|
import { isQuotePacked, isRenotePacked } from '@/misc/is-renote.js';
|
||||||
@@ -30,6 +31,7 @@ export class LocalTimelineChannel extends Channel {
|
|||||||
private metaService: MetaService,
|
private metaService: MetaService,
|
||||||
private roleService: RoleService,
|
private roleService: RoleService,
|
||||||
private noteEntityService: NoteEntityService,
|
private noteEntityService: NoteEntityService,
|
||||||
|
private noteStreamingHidingService: NoteStreamingHidingService,
|
||||||
) {
|
) {
|
||||||
super(request);
|
super(request);
|
||||||
//this.onNote = this.onNote.bind(this);
|
//this.onNote = this.onNote.bind(this);
|
||||||
@@ -70,10 +72,15 @@ export class LocalTimelineChannel extends Channel {
|
|||||||
|
|
||||||
if (this.isNoteMutedOrBlocked(note)) return;
|
if (this.isNoteMutedOrBlocked(note)) return;
|
||||||
|
|
||||||
if (this.user && isRenotePacked(note) && !isQuotePacked(note)) {
|
const { shouldSkip } = await this.noteStreamingHidingService.processHiding(note, this.user?.id ?? null);
|
||||||
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
if (shouldSkip) return;
|
||||||
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
|
||||||
note.renote.myReaction = myRenoteReaction;
|
if (this.user) {
|
||||||
|
if (isRenotePacked(note) && !isQuotePacked(note)) {
|
||||||
|
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
||||||
|
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
||||||
|
note.renote.myReaction = myRenoteReaction;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ export class MainChannel extends Channel {
|
|||||||
}
|
}
|
||||||
case 'mention': {
|
case 'mention': {
|
||||||
if (isInstanceMuted(data.body, new Set<string>(this.userProfile?.mutedInstances ?? []))) return;
|
if (isInstanceMuted(data.body, new Set<string>(this.userProfile?.mutedInstances ?? []))) return;
|
||||||
|
if (!this.isNoteVisibleForMe(data.body)) return;
|
||||||
if (this.userIdsWhoMeMuting.has(data.body.userId)) return;
|
if (this.isNoteMutedOrBlocked(data.body)) return;
|
||||||
if (data.body.isHidden) {
|
if (data.body.isHidden) {
|
||||||
const note = await this.noteEntityService.pack(data.body.id, this.user, {
|
const note = await this.noteEntityService.pack(data.body.id, this.user, {
|
||||||
detail: true,
|
detail: true,
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import { Inject, Injectable, Scope } from '@nestjs/common';
|
|||||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { RoleService } from '@/core/RoleService.js';
|
import { RoleService } from '@/core/RoleService.js';
|
||||||
|
import { NoteStreamingHidingService } from '../NoteStreamingHidingService.js';
|
||||||
|
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
|
||||||
import type { GlobalEvents } from '@/core/GlobalEventService.js';
|
import type { GlobalEvents } from '@/core/GlobalEventService.js';
|
||||||
import type { JsonObject } from '@/misc/json-value.js';
|
import type { JsonObject } from '@/misc/json-value.js';
|
||||||
import Channel, { type ChannelRequest } from '../channel.js';
|
import Channel, { type ChannelRequest } from '../channel.js';
|
||||||
@@ -25,6 +27,7 @@ export class RoleTimelineChannel extends Channel {
|
|||||||
|
|
||||||
private noteEntityService: NoteEntityService,
|
private noteEntityService: NoteEntityService,
|
||||||
private roleservice: RoleService,
|
private roleservice: RoleService,
|
||||||
|
private noteStreamingHidingService: NoteStreamingHidingService,
|
||||||
) {
|
) {
|
||||||
super(request);
|
super(request);
|
||||||
//this.onNote = this.onNote.bind(this);
|
//this.onNote = this.onNote.bind(this);
|
||||||
@@ -47,9 +50,24 @@ export class RoleTimelineChannel extends Channel {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (note.visibility !== 'public') return;
|
if (note.visibility !== 'public') return;
|
||||||
|
if (note.user.requireSigninToViewContents && this.user == null) return;
|
||||||
|
if (note.renote && note.renote.user.requireSigninToViewContents && this.user == null) return;
|
||||||
|
if (note.reply && note.reply.user.requireSigninToViewContents && this.user == null) return;
|
||||||
|
|
||||||
if (this.isNoteMutedOrBlocked(note)) return;
|
if (this.isNoteMutedOrBlocked(note)) return;
|
||||||
|
|
||||||
|
const { shouldSkip } = await this.noteStreamingHidingService.processHiding(note, this.user?.id ?? null);
|
||||||
|
if (shouldSkip) return;
|
||||||
|
|
||||||
|
if (this.user) {
|
||||||
|
if (isRenotePacked(note) && !isQuotePacked(note)) {
|
||||||
|
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
||||||
|
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
||||||
|
note.renote.myReaction = myRenoteReaction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.send('note', note);
|
this.send('note', note);
|
||||||
} else {
|
} else {
|
||||||
this.send(data.type, data.body);
|
this.send(data.type, data.body);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { Inject, Injectable, Scope } from '@nestjs/common';
|
|||||||
import type { MiUserListMembership, UserListMembershipsRepository, UserListsRepository } from '@/models/_.js';
|
import type { MiUserListMembership, UserListMembershipsRepository, UserListsRepository } from '@/models/_.js';
|
||||||
import type { Packed } from '@/misc/json-schema.js';
|
import type { Packed } from '@/misc/json-schema.js';
|
||||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
|
import { NoteStreamingHidingService } from '../NoteStreamingHidingService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
|
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
|
||||||
@@ -36,6 +37,7 @@ export class UserListChannel extends Channel {
|
|||||||
request: ChannelRequest,
|
request: ChannelRequest,
|
||||||
|
|
||||||
private noteEntityService: NoteEntityService,
|
private noteEntityService: NoteEntityService,
|
||||||
|
private noteStreamingHidingService: NoteStreamingHidingService,
|
||||||
) {
|
) {
|
||||||
super(request);
|
super(request);
|
||||||
//this.updateListUsers = this.updateListUsers.bind(this);
|
//this.updateListUsers = this.updateListUsers.bind(this);
|
||||||
@@ -96,11 +98,7 @@ export class UserListChannel extends Channel {
|
|||||||
|
|
||||||
if (!Object.hasOwn(this.membershipsMap, note.userId)) return;
|
if (!Object.hasOwn(this.membershipsMap, note.userId)) return;
|
||||||
|
|
||||||
if (note.visibility === 'followers') {
|
if (!this.isNoteVisibleForMe(note)) return;
|
||||||
if (!isMe && !Object.hasOwn(this.following, note.userId)) return;
|
|
||||||
} else if (note.visibility === 'specified') {
|
|
||||||
if (!note.visibleUserIds!.includes(this.user!.id)) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (note.reply) {
|
if (note.reply) {
|
||||||
const reply = note.reply;
|
const reply = note.reply;
|
||||||
@@ -117,10 +115,15 @@ export class UserListChannel extends Channel {
|
|||||||
|
|
||||||
if (this.isNoteMutedOrBlocked(note)) return;
|
if (this.isNoteMutedOrBlocked(note)) return;
|
||||||
|
|
||||||
if (this.user && isRenotePacked(note) && !isQuotePacked(note)) {
|
const { shouldSkip } = await this.noteStreamingHidingService.processHiding(note, this.user?.id ?? null);
|
||||||
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
if (shouldSkip) return;
|
||||||
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
|
||||||
note.renote.myReaction = myRenoteReaction;
|
if (this.user) {
|
||||||
|
if (isRenotePacked(note) && !isQuotePacked(note)) {
|
||||||
|
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
||||||
|
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
||||||
|
note.renote.myReaction = myRenoteReaction;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user