Loosen block restrictions
This commit is contained in:
		
							parent
							
								
									2991122668
								
							
						
					
					
						commit
						a851b94b01
					
				
					 10 changed files with 86 additions and 19 deletions
				
			
		| 
						 | 
					@ -13,6 +13,7 @@ import type { NotesRepository } from '@/models/_.js';
 | 
				
			||||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
 | 
					import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
 | 
				
			||||||
import { FanoutTimelineName, FanoutTimelineService } from '@/core/FanoutTimelineService.js';
 | 
					import { FanoutTimelineName, FanoutTimelineService } from '@/core/FanoutTimelineService.js';
 | 
				
			||||||
import { isUserRelated } from '@/misc/is-user-related.js';
 | 
					import { isUserRelated } from '@/misc/is-user-related.js';
 | 
				
			||||||
 | 
					import { isUserMentioned } from '@/misc/is-user-mentioned.js';
 | 
				
			||||||
import { isQuote, isRenote } from '@/misc/is-renote.js';
 | 
					import { isQuote, isRenote } from '@/misc/is-renote.js';
 | 
				
			||||||
import { CacheService } from '@/core/CacheService.js';
 | 
					import { CacheService } from '@/core/CacheService.js';
 | 
				
			||||||
import { isReply } from '@/misc/is-reply.js';
 | 
					import { isReply } from '@/misc/is-reply.js';
 | 
				
			||||||
| 
						 | 
					@ -30,6 +31,7 @@ type TimelineOptions = {
 | 
				
			||||||
	alwaysIncludeMyNotes?: boolean;
 | 
						alwaysIncludeMyNotes?: boolean;
 | 
				
			||||||
	ignoreAuthorFromBlock?: boolean;
 | 
						ignoreAuthorFromBlock?: boolean;
 | 
				
			||||||
	ignoreAuthorFromMute?: boolean;
 | 
						ignoreAuthorFromMute?: boolean;
 | 
				
			||||||
 | 
						ignoreMentionsFromBlock?: boolean;
 | 
				
			||||||
	excludeNoFiles?: boolean;
 | 
						excludeNoFiles?: boolean;
 | 
				
			||||||
	excludeReplies?: boolean;
 | 
						excludeReplies?: boolean;
 | 
				
			||||||
	excludeBots?: boolean;
 | 
						excludeBots?: boolean;
 | 
				
			||||||
| 
						 | 
					@ -106,17 +108,25 @@ export class FanoutTimelineEndpointService {
 | 
				
			||||||
					userIdsWhoMeMuting,
 | 
										userIdsWhoMeMuting,
 | 
				
			||||||
					userIdsWhoMeMutingRenotes,
 | 
										userIdsWhoMeMutingRenotes,
 | 
				
			||||||
					userIdsWhoBlockingMe,
 | 
										userIdsWhoBlockingMe,
 | 
				
			||||||
 | 
										userIdsWhoMeBlocking,
 | 
				
			||||||
					userMutedInstances,
 | 
										userMutedInstances,
 | 
				
			||||||
				] = await Promise.all([
 | 
									] = await Promise.all([
 | 
				
			||||||
					this.cacheService.userMutingsCache.fetch(ps.me.id),
 | 
										this.cacheService.userMutingsCache.fetch(ps.me.id),
 | 
				
			||||||
					this.cacheService.renoteMutingsCache.fetch(ps.me.id),
 | 
										this.cacheService.renoteMutingsCache.fetch(ps.me.id),
 | 
				
			||||||
					this.cacheService.userBlockedCache.fetch(ps.me.id),
 | 
										this.cacheService.userBlockedCache.fetch(ps.me.id),
 | 
				
			||||||
 | 
										this.cacheService.userBlockingCache.fetch(ps.me.id),
 | 
				
			||||||
					this.cacheService.userProfileCache.fetch(me.id).then(p => new Set(p.mutedInstances)),
 | 
										this.cacheService.userProfileCache.fetch(me.id).then(p => new Set(p.mutedInstances)),
 | 
				
			||||||
				]);
 | 
									]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				const parentFilter = filter;
 | 
									const parentFilter = filter;
 | 
				
			||||||
				filter = (note) => {
 | 
									filter = (note) => {
 | 
				
			||||||
					if (isUserRelated(note, userIdsWhoBlockingMe, ps.ignoreAuthorFromBlock)) return false;
 | 
										if (isUserRelated(note, userIdsWhoBlockingMe, ps.ignoreAuthorFromBlock)) return false;
 | 
				
			||||||
 | 
										if (isUserRelated(note, userIdsWhoMeBlocking, ps.ignoreAuthorFromBlock)) return false;
 | 
				
			||||||
 | 
										const ignoreMentions = ps.ignoreMentionsFromBlock ?? ps.ignoreAuthorFromBlock;
 | 
				
			||||||
 | 
										if (ignoreMentions) {
 | 
				
			||||||
 | 
					    					if (isUserMentioned(note, userIdsWhoBlockingMe)) return false;
 | 
				
			||||||
 | 
					    					if (isUserMentioned(note, userIdsWhoMeBlocking)) return false;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
					if (isUserRelated(note, userIdsWhoMeMuting, ps.ignoreAuthorFromMute)) return false;
 | 
										if (isUserRelated(note, userIdsWhoMeMuting, ps.ignoreAuthorFromMute)) return false;
 | 
				
			||||||
					if (!ps.ignoreAuthorFromMute && isRenote(note) && !isQuote(note) && userIdsWhoMeMutingRenotes.has(note.userId)) return false;
 | 
										if (!ps.ignoreAuthorFromMute && isRenote(note) && !isQuote(note) && userIdsWhoMeMutingRenotes.has(note.userId)) return false;
 | 
				
			||||||
					if (isInstanceMuted(note, userMutedInstances)) return false;
 | 
										if (isInstanceMuted(note, userMutedInstances)) return false;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -79,6 +79,7 @@ export class QueryService {
 | 
				
			||||||
			.where('blocking.blockeeId = :blockeeId', { blockeeId: me.id });
 | 
								.where('blocking.blockeeId = :blockeeId', { blockeeId: me.id });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		const mentionQuery = `SELECT COUNT(*) FROM unnest(note.mentions) mention WHERE mention IN (${blockingQuery.getQuery()}) OR mention IN (${blockedQuery.getQuery()}) LIMIT 1`;
 | 
							const mentionQuery = `SELECT COUNT(*) FROM unnest(note.mentions) mention WHERE mention IN (${blockingQuery.getQuery()}) OR mention IN (${blockedQuery.getQuery()}) LIMIT 1`;
 | 
				
			||||||
 | 
							const mentionMeQuery = `SELECT COUNT(*) FROM unnest(note.mentions) mention WHERE mention = :meId LIMIT 1`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// 投稿の作者にブロックされていない かつ
 | 
							// 投稿の作者にブロックされていない かつ
 | 
				
			||||||
		// 投稿の返信先の作者にブロックされていない かつ
 | 
							// 投稿の返信先の作者にブロックされていない かつ
 | 
				
			||||||
| 
						 | 
					@ -98,7 +99,13 @@ export class QueryService {
 | 
				
			||||||
					.orWhere(`note.renoteUserId NOT IN (${ blockedQuery.getQuery() })`)
 | 
										.orWhere(`note.renoteUserId NOT IN (${ blockedQuery.getQuery() })`)
 | 
				
			||||||
					.orWhere(`note.renoteUserId NOT IN (${ blockingQuery.getQuery() })`);
 | 
										.orWhere(`note.renoteUserId NOT IN (${ blockingQuery.getQuery() })`);
 | 
				
			||||||
			}))
 | 
								}))
 | 
				
			||||||
			.andWhere(`(${mentionQuery}) = 0`);
 | 
								.andWhere(new Brackets(qb => {
 | 
				
			||||||
 | 
					    			qb
 | 
				
			||||||
 | 
					    				.where(`(${mentionQuery}) = 0`)
 | 
				
			||||||
 | 
					    				.orWhere('note.userId = :meId', { meId: me.id })
 | 
				
			||||||
 | 
					    				.orWhere('note.replyUserId = :meId', { meId: me.id })
 | 
				
			||||||
 | 
					    				.orWhere(`(${mentionMeQuery}) = 1`, { meId: me.id });
 | 
				
			||||||
 | 
								}));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		q.setParameters(blockingQuery.getParameters());
 | 
							q.setParameters(blockingQuery.getParameters());
 | 
				
			||||||
		q.setParameters(blockedQuery.getParameters());
 | 
							q.setParameters(blockedQuery.getParameters());
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -236,14 +236,17 @@ export class SearchService {
 | 
				
			||||||
			const [
 | 
								const [
 | 
				
			||||||
				userIdsWhoMeMuting,
 | 
									userIdsWhoMeMuting,
 | 
				
			||||||
				userIdsWhoBlockingMe,
 | 
									userIdsWhoBlockingMe,
 | 
				
			||||||
 | 
									userIdsWhoMeBlocking,
 | 
				
			||||||
			] = me ? await Promise.all([
 | 
								] = me ? await Promise.all([
 | 
				
			||||||
				this.cacheService.userMutingsCache.fetch(me.id),
 | 
									this.cacheService.userMutingsCache.fetch(me.id),
 | 
				
			||||||
				this.cacheService.userBlockedCache.fetch(me.id),
 | 
									this.cacheService.userBlockedCache.fetch(me.id),
 | 
				
			||||||
 | 
									this.cacheService.userBlockingCache.fetch(me.id),
 | 
				
			||||||
			]) : [new Set<string>(), new Set<string>()];
 | 
								]) : [new Set<string>(), new Set<string>()];
 | 
				
			||||||
			const notes = (await this.notesRepository.findBy({
 | 
								const notes = (await this.notesRepository.findBy({
 | 
				
			||||||
				id: In(res.hits.map(x => x.id)),
 | 
									id: In(res.hits.map(x => x.id)),
 | 
				
			||||||
			})).filter(note => {
 | 
								})).filter(note => {
 | 
				
			||||||
				if (me && isUserRelated(note, userIdsWhoBlockingMe)) return false;
 | 
									if (me && isUserRelated(note, userIdsWhoBlockingMe)) return false;
 | 
				
			||||||
 | 
									if (me && isUserRelated(note, userIdsWhoMeBlocking)) return false;
 | 
				
			||||||
				if (me && isUserRelated(note, userIdsWhoMeMuting)) return false;
 | 
									if (me && isUserRelated(note, userIdsWhoMeMuting)) return false;
 | 
				
			||||||
				return true;
 | 
									return true;
 | 
				
			||||||
			});
 | 
								});
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										20
									
								
								packages/backend/src/misc/is-user-mentioned.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								packages/backend/src/misc/is-user-mentioned.ts
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,20 @@
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * SPDX-FileCopyrightText: syuilo and misskey-project
 | 
				
			||||||
 | 
					 * SPDX-License-Identifier: AGPL-3.0-only
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export function isUserMentioned(note: any, userIds: Set<string>): boolean {
 | 
				
			||||||
 | 
						if (!note) {
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (note.mentions != null && note.mentions.some(mention => userIds.has(mention))) {
 | 
				
			||||||
 | 
					    	return true;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (note.renote != null && note.renote.mentions != null && note.renote.mentions.some(mention => userIds.has(mention))) {
 | 
				
			||||||
 | 
					    	return true;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return false;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -4,8 +4,6 @@
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function isUserRelated(note: any, userIds: Set<string>, ignoreAuthor = false): boolean {
 | 
					export function isUserRelated(note: any, userIds: Set<string>, ignoreAuthor = false): boolean {
 | 
				
			||||||
	console.log(note);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!note) {
 | 
						if (!note) {
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -22,13 +20,5 @@ export function isUserRelated(note: any, userIds: Set<string>, ignoreAuthor = fa
 | 
				
			||||||
		return true;
 | 
							return true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!ignoreAuthor && note.mentions != null && note.mentions.some(mention => userIds.has(mention))) {
 | 
					 | 
				
			||||||
    	return true;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!ignoreAuthor && note.renote != null && note.renote.mentions != null && note.renote.mentions.some(mention => userIds.has(mention))) {
 | 
					 | 
				
			||||||
    	return true;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return false;
 | 
						return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,6 +10,8 @@ import { Endpoint } from '@/server/api/endpoint-base.js';
 | 
				
			||||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
 | 
					import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
 | 
				
			||||||
import { DI } from '@/di-symbols.js';
 | 
					import { DI } from '@/di-symbols.js';
 | 
				
			||||||
import { GetterService } from '@/server/api/GetterService.js';
 | 
					import { GetterService } from '@/server/api/GetterService.js';
 | 
				
			||||||
 | 
					import { CacheService } from '@/core/CacheService.js';
 | 
				
			||||||
 | 
					import { RoleService } from '@/core/RoleService.js';
 | 
				
			||||||
import { ApiError } from '../../error.js';
 | 
					import { ApiError } from '../../error.js';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const meta = {
 | 
					export const meta = {
 | 
				
			||||||
| 
						 | 
					@ -55,15 +57,23 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		private noteEntityService: NoteEntityService,
 | 
							private noteEntityService: NoteEntityService,
 | 
				
			||||||
		private getterService: GetterService,
 | 
							private getterService: GetterService,
 | 
				
			||||||
 | 
							private cacheService: CacheService,
 | 
				
			||||||
 | 
							private roleService: RoleService,
 | 
				
			||||||
	) {
 | 
						) {
 | 
				
			||||||
		super(meta, paramDef, async (ps, me) => {
 | 
							super(meta, paramDef, async (ps, me) => {
 | 
				
			||||||
			const note = await this.getterService.getNote(ps.noteId).catch(err => {
 | 
								const [userIdsWhoBlockingMe, userIdsWhoMeBlocking, isModerator, note] = await Promise.all([
 | 
				
			||||||
 | 
									me != null && this.cacheService.userBlockedCache.fetch(me.id),
 | 
				
			||||||
 | 
									me != null && this.cacheService.userBlockingCache.fetch(me.id),
 | 
				
			||||||
 | 
									me != null && this.roleService.isModerator(me),
 | 
				
			||||||
 | 
									this.getterService.getNote(ps.noteId).catch(err => {
 | 
				
			||||||
					if (err.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
 | 
										if (err.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
 | 
				
			||||||
					throw err;
 | 
										throw err;
 | 
				
			||||||
			});
 | 
									}),
 | 
				
			||||||
 | 
								]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			const conversation: MiNote[] = [];
 | 
								const conversation: MiNote[] = [];
 | 
				
			||||||
			let i = 0;
 | 
								let i = 0;
 | 
				
			||||||
 | 
								let length = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			const get = async (id: any) => {
 | 
								const get = async (id: any) => {
 | 
				
			||||||
				i++;
 | 
									i++;
 | 
				
			||||||
| 
						 | 
					@ -71,10 +81,17 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
 | 
				
			||||||
				if (p == null) return;
 | 
									if (p == null) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if (i > ps.offset!) {
 | 
									if (i > ps.offset!) {
 | 
				
			||||||
 | 
										if (me == null ||
 | 
				
			||||||
 | 
											isModerator ||
 | 
				
			||||||
 | 
											!(userIdsWhoBlockingMe.has(p.userId) || userIdsWhoMeBlocking.has(p.userId))
 | 
				
			||||||
 | 
										) {
 | 
				
			||||||
						conversation.push(p);
 | 
											conversation.push(p);
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if (conversation.length === ps.limit) {
 | 
										length += 1;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if (length === ps.limit) {
 | 
				
			||||||
					return;
 | 
										return;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,6 +10,7 @@ import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
 | 
				
			||||||
import { DI } from '@/di-symbols.js';
 | 
					import { DI } from '@/di-symbols.js';
 | 
				
			||||||
import { FeaturedService } from '@/core/FeaturedService.js';
 | 
					import { FeaturedService } from '@/core/FeaturedService.js';
 | 
				
			||||||
import { isUserRelated } from '@/misc/is-user-related.js';
 | 
					import { isUserRelated } from '@/misc/is-user-related.js';
 | 
				
			||||||
 | 
					import { isUserMentioned } from '@/misc/is-user-mentioned.js';
 | 
				
			||||||
import { CacheService } from '@/core/CacheService.js';
 | 
					import { CacheService } from '@/core/CacheService.js';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const meta = {
 | 
					export const meta = {
 | 
				
			||||||
| 
						 | 
					@ -81,9 +82,11 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
 | 
				
			||||||
			const [
 | 
								const [
 | 
				
			||||||
				userIdsWhoMeMuting,
 | 
									userIdsWhoMeMuting,
 | 
				
			||||||
				userIdsWhoBlockingMe,
 | 
									userIdsWhoBlockingMe,
 | 
				
			||||||
 | 
									userIdsWhoMeBlocking,
 | 
				
			||||||
			] = me ? await Promise.all([
 | 
								] = me ? await Promise.all([
 | 
				
			||||||
				this.cacheService.userMutingsCache.fetch(me.id),
 | 
									this.cacheService.userMutingsCache.fetch(me.id),
 | 
				
			||||||
				this.cacheService.userBlockedCache.fetch(me.id),
 | 
									this.cacheService.userBlockedCache.fetch(me.id),
 | 
				
			||||||
 | 
									this.cacheService.userBlockingCache.fetch(me.id),
 | 
				
			||||||
			]) : [new Set<string>(), new Set<string>()];
 | 
								]) : [new Set<string>(), new Set<string>()];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			const query = this.notesRepository.createQueryBuilder('note')
 | 
								const query = this.notesRepository.createQueryBuilder('note')
 | 
				
			||||||
| 
						 | 
					@ -97,8 +100,12 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			const notes = (await query.getMany()).filter(note => {
 | 
								const notes = (await query.getMany()).filter(note => {
 | 
				
			||||||
				if (me && isUserRelated(note, userIdsWhoBlockingMe)) return false;
 | 
									if (me && isUserRelated(note, userIdsWhoBlockingMe)) return false;
 | 
				
			||||||
 | 
									if (me && isUserRelated(note, userIdsWhoMeBlocking)) return false;
 | 
				
			||||||
				if (me && isUserRelated(note, userIdsWhoMeMuting)) return false;
 | 
									if (me && isUserRelated(note, userIdsWhoMeMuting)) return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if (me && isUserMentioned(note, userIdsWhoBlockingMe)) return false;
 | 
				
			||||||
 | 
									if (me && isUserMentioned(note, userIdsWhoMeBlocking)) return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				return true;
 | 
									return true;
 | 
				
			||||||
			});
 | 
								});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,6 +11,7 @@ import { DI } from '@/di-symbols.js';
 | 
				
			||||||
import { FeaturedService } from '@/core/FeaturedService.js';
 | 
					import { FeaturedService } from '@/core/FeaturedService.js';
 | 
				
			||||||
import { CacheService } from '@/core/CacheService.js';
 | 
					import { CacheService } from '@/core/CacheService.js';
 | 
				
			||||||
import { isUserRelated } from '@/misc/is-user-related.js';
 | 
					import { isUserRelated } from '@/misc/is-user-related.js';
 | 
				
			||||||
 | 
					import { isUserMentioned } from '@/misc/is-user-mentioned.js';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const meta = {
 | 
					export const meta = {
 | 
				
			||||||
	tags: ['notes'],
 | 
						tags: ['notes'],
 | 
				
			||||||
| 
						 | 
					@ -53,9 +54,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
 | 
				
			||||||
	) {
 | 
						) {
 | 
				
			||||||
		super(meta, paramDef, async (ps, me) => {
 | 
							super(meta, paramDef, async (ps, me) => {
 | 
				
			||||||
			const userIdsWhoBlockingMe = me ? await this.cacheService.userBlockedCache.fetch(me.id) : new Set<string>();
 | 
								const userIdsWhoBlockingMe = me ? await this.cacheService.userBlockedCache.fetch(me.id) : new Set<string>();
 | 
				
			||||||
 | 
								const userIdsWhoMeBlocking = me ? await this.cacheService.userBlockingCache.fetch(me.id) : new Set<string>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// early return if me is blocked by requesting user
 | 
								// early return if me is blocked by requesting user
 | 
				
			||||||
			if (userIdsWhoBlockingMe.has(ps.userId)) {
 | 
								if (userIdsWhoBlockingMe.has(ps.userId) || userIdsWhoMeBlocking.has(ps.userId)) {
 | 
				
			||||||
				return [];
 | 
									return [];
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -90,6 +92,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
 | 
				
			||||||
				if (me && isUserRelated(note, userIdsWhoBlockingMe, false)) return false;
 | 
									if (me && isUserRelated(note, userIdsWhoBlockingMe, false)) return false;
 | 
				
			||||||
				if (me && isUserRelated(note, userIdsWhoMeMuting, true)) return false;
 | 
									if (me && isUserRelated(note, userIdsWhoMeMuting, true)) return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if (me && isUserMentioned(note, userIdsWhoBlockingMe)) return false;
 | 
				
			||||||
 | 
									if (me && isUserMentioned(note, userIdsWhoMeBlocking)) return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				return true;
 | 
									return true;
 | 
				
			||||||
			});
 | 
								});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,6 +13,7 @@ import { CacheService } from '@/core/CacheService.js';
 | 
				
			||||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
 | 
					import { UserEntityService } from '@/core/entities/UserEntityService.js';
 | 
				
			||||||
import { RoleService } from '@/core/RoleService.js';
 | 
					import { RoleService } from '@/core/RoleService.js';
 | 
				
			||||||
import { isUserRelated } from '@/misc/is-user-related.js';
 | 
					import { isUserRelated } from '@/misc/is-user-related.js';
 | 
				
			||||||
 | 
					import { isUserMentioned } from '@/misc/is-user-mentioned.js';
 | 
				
			||||||
import { ApiError } from '../../error.js';
 | 
					import { ApiError } from '../../error.js';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const meta = {
 | 
					export const meta = {
 | 
				
			||||||
| 
						 | 
					@ -77,6 +78,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
 | 
				
			||||||
	) {
 | 
						) {
 | 
				
			||||||
		super(meta, paramDef, async (ps, me) => {
 | 
							super(meta, paramDef, async (ps, me) => {
 | 
				
			||||||
			const userIdsWhoBlockingMe = me ? await this.cacheService.userBlockedCache.fetch(me.id) : new Set<string>();
 | 
								const userIdsWhoBlockingMe = me ? await this.cacheService.userBlockedCache.fetch(me.id) : new Set<string>();
 | 
				
			||||||
 | 
								const userIdsWhoMeBlocking = me ? await this.cacheService.userBlockingCache.fetch(me.id) : new Set<string>();
 | 
				
			||||||
			const iAmModerator = me ? await this.roleService.isModerator(me) : false; // Moderators can see reactions of all users
 | 
								const iAmModerator = me ? await this.roleService.isModerator(me) : false; // Moderators can see reactions of all users
 | 
				
			||||||
			if (!iAmModerator) {
 | 
								if (!iAmModerator) {
 | 
				
			||||||
				const user = await this.cacheService.findUserById(ps.userId);
 | 
									const user = await this.cacheService.findUserById(ps.userId);
 | 
				
			||||||
| 
						 | 
					@ -90,7 +92,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				// early return if me is blocked by requesting user
 | 
									// early return if me is blocked by requesting user
 | 
				
			||||||
				if (userIdsWhoBlockingMe.has(ps.userId)) {
 | 
									if (userIdsWhoBlockingMe.has(ps.userId) || userIdsWhoMeBlocking.has(ps.userId)) {
 | 
				
			||||||
					return [];
 | 
										return [];
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
| 
						 | 
					@ -111,6 +113,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
 | 
				
			||||||
				if (me && isUserRelated(reaction.note, userIdsWhoBlockingMe)) return false;
 | 
									if (me && isUserRelated(reaction.note, userIdsWhoBlockingMe)) return false;
 | 
				
			||||||
				if (me && isUserRelated(reaction.note, userIdsWhoMeMuting)) return false;
 | 
									if (me && isUserRelated(reaction.note, userIdsWhoMeMuting)) return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if (me && isUserMentioned(note, userIdsWhoBlockingMe)) return false;
 | 
				
			||||||
 | 
									if (me && isUserMentioned(note, userIdsWhoMeBlocking)) return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				return true;
 | 
									return true;
 | 
				
			||||||
			});
 | 
								});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,6 +6,7 @@
 | 
				
			||||||
import { bindThis } from '@/decorators.js';
 | 
					import { bindThis } from '@/decorators.js';
 | 
				
			||||||
import { isInstanceMuted } from '@/misc/is-instance-muted.js';
 | 
					import { isInstanceMuted } from '@/misc/is-instance-muted.js';
 | 
				
			||||||
import { isUserRelated } from '@/misc/is-user-related.js';
 | 
					import { isUserRelated } from '@/misc/is-user-related.js';
 | 
				
			||||||
 | 
					import { isUserMentioned } from '@/misc/is-user-mentioned.js';
 | 
				
			||||||
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
 | 
					import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
 | 
				
			||||||
import type { Packed } from '@/misc/json-schema.js';
 | 
					import type { Packed } from '@/misc/json-schema.js';
 | 
				
			||||||
import type { JsonObject, JsonValue } from '@/misc/json-value.js';
 | 
					import type { JsonObject, JsonValue } from '@/misc/json-value.js';
 | 
				
			||||||
| 
						 | 
					@ -76,6 +77,8 @@ export default abstract class Channel {
 | 
				
			||||||
		if (isUserRelated(note, this.userIdsWhoBlockingMe)) return true;
 | 
							if (isUserRelated(note, this.userIdsWhoBlockingMe)) return true;
 | 
				
			||||||
		if (isUserRelated(note, this.userIdsWhoMeBlocking)) return true;
 | 
							if (isUserRelated(note, this.userIdsWhoMeBlocking)) return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (isUserMentioned(note, this.userIdsWhoMeBlocking) && !isUserMentioned(note, [ this.user().id ])) return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// 流れてきたNoteがリノートをミュートしてるユーザが行ったもの
 | 
							// 流れてきたNoteがリノートをミュートしてるユーザが行ったもの
 | 
				
			||||||
		if (isRenotePacked(note) && !isQuotePacked(note) && this.userIdsWhoMeMutingRenotes.has(note.user.id)) return true;
 | 
							if (isRenotePacked(note) && !isQuotePacked(note) && this.userIdsWhoMeMutingRenotes.has(note.user.id)) return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue