Exclude blocked instance note from most timelines (#15792)
* Exclude blocked instance note from most timelines * Exclude blocked instance note from FTT timelines * Exclude blocked instance note from featured * fix type
This commit is contained in:
parent
7581331713
commit
ec92bf47f1
|
@ -8,10 +8,12 @@ import { DI } from '@/di-symbols.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import type { MiUser } from '@/models/User.js';
|
import type { MiUser } from '@/models/User.js';
|
||||||
import type { MiNote } from '@/models/Note.js';
|
import type { MiNote } from '@/models/Note.js';
|
||||||
|
import type { MiMeta } from '@/models/Meta.js';
|
||||||
import { Packed } from '@/misc/json-schema.js';
|
import { Packed } from '@/misc/json-schema.js';
|
||||||
import type { NotesRepository } from '@/models/_.js';
|
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 { UtilityService } from '@/core/UtilityService.js';
|
||||||
import { isUserRelated } from '@/misc/is-user-related.js';
|
import { isUserRelated } from '@/misc/is-user-related.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';
|
||||||
|
@ -30,6 +32,7 @@ type TimelineOptions = {
|
||||||
alwaysIncludeMyNotes?: boolean;
|
alwaysIncludeMyNotes?: boolean;
|
||||||
ignoreAuthorFromBlock?: boolean;
|
ignoreAuthorFromBlock?: boolean;
|
||||||
ignoreAuthorFromMute?: boolean;
|
ignoreAuthorFromMute?: boolean;
|
||||||
|
ignoreAuthorFromInstanceBlock?: boolean;
|
||||||
excludeNoFiles?: boolean;
|
excludeNoFiles?: boolean;
|
||||||
excludeReplies?: boolean;
|
excludeReplies?: boolean;
|
||||||
excludePureRenotes: boolean;
|
excludePureRenotes: boolean;
|
||||||
|
@ -42,9 +45,13 @@ export class FanoutTimelineEndpointService {
|
||||||
@Inject(DI.notesRepository)
|
@Inject(DI.notesRepository)
|
||||||
private notesRepository: NotesRepository,
|
private notesRepository: NotesRepository,
|
||||||
|
|
||||||
|
@Inject(DI.meta)
|
||||||
|
private meta: MiMeta,
|
||||||
|
|
||||||
private noteEntityService: NoteEntityService,
|
private noteEntityService: NoteEntityService,
|
||||||
private cacheService: CacheService,
|
private cacheService: CacheService,
|
||||||
private fanoutTimelineService: FanoutTimelineService,
|
private fanoutTimelineService: FanoutTimelineService,
|
||||||
|
private utilityService: UtilityService,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,6 +126,19 @@ export class FanoutTimelineEndpointService {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const parentFilter = filter;
|
||||||
|
filter = (note) => {
|
||||||
|
if (!ps.ignoreAuthorFromInstanceBlock) {
|
||||||
|
if (this.utilityService.isBlockedHost(this.meta.blockedHosts, note.userHost)) return false;
|
||||||
|
}
|
||||||
|
if (note.userId !== note.renoteUserId && this.utilityService.isBlockedHost(this.meta.blockedHosts, note.renoteUserHost)) return false;
|
||||||
|
if (note.userId !== note.replyUserId && this.utilityService.isBlockedHost(this.meta.blockedHosts, note.replyUserHost)) return false;
|
||||||
|
|
||||||
|
return parentFilter(note);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const redisTimeline: MiNote[] = [];
|
const redisTimeline: MiNote[] = [];
|
||||||
let readFromRedis = 0;
|
let readFromRedis = 0;
|
||||||
let lastSuccessfulRate = 1; // rateをキャッシュする?
|
let lastSuccessfulRate = 1; // rateをキャッシュする?
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { Brackets, ObjectLiteral } from 'typeorm';
|
import { Brackets, ObjectLiteral } from 'typeorm';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import type { MiUser } from '@/models/User.js';
|
import type { MiUser } from '@/models/User.js';
|
||||||
import type { UserProfilesRepository, FollowingsRepository, ChannelFollowingsRepository, BlockingsRepository, NoteThreadMutingsRepository, MutingsRepository, RenoteMutingsRepository } from '@/models/_.js';
|
import type { UserProfilesRepository, FollowingsRepository, ChannelFollowingsRepository, BlockingsRepository, NoteThreadMutingsRepository, MutingsRepository, RenoteMutingsRepository, MiMeta } from '@/models/_.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { IdService } from '@/core/IdService.js';
|
import { IdService } from '@/core/IdService.js';
|
||||||
import type { SelectQueryBuilder } from 'typeorm';
|
import type { SelectQueryBuilder } from 'typeorm';
|
||||||
|
@ -36,6 +36,9 @@ export class QueryService {
|
||||||
@Inject(DI.renoteMutingsRepository)
|
@Inject(DI.renoteMutingsRepository)
|
||||||
private renoteMutingsRepository: RenoteMutingsRepository,
|
private renoteMutingsRepository: RenoteMutingsRepository,
|
||||||
|
|
||||||
|
@Inject(DI.meta)
|
||||||
|
private meta: MiMeta,
|
||||||
|
|
||||||
private idService: IdService,
|
private idService: IdService,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
@ -251,4 +254,37 @@ export class QueryService {
|
||||||
|
|
||||||
q.setParameters(mutingQuery.getParameters());
|
q.setParameters(mutingQuery.getParameters());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public generateBlockedHostQueryForNote(q: SelectQueryBuilder<any>, excludeAuthor?: boolean): void {
|
||||||
|
let nonBlockedHostQuery: (part: string) => string;
|
||||||
|
if (this.meta.blockedHosts.length === 0) {
|
||||||
|
nonBlockedHostQuery = () => '1=1';
|
||||||
|
} else {
|
||||||
|
nonBlockedHostQuery = (match: string) => `${match} NOT ILIKE ALL(ARRAY[:...blocked])`;
|
||||||
|
q.setParameters({ blocked: this.meta.blockedHosts.flatMap(x => [x, `%.${x}`]) });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (excludeAuthor) {
|
||||||
|
const instanceSuspension = (user: string) => new Brackets(qb => qb
|
||||||
|
.where(`note.${user}Id IS NULL`) // no corresponding user
|
||||||
|
.orWhere(`note.userId = note.${user}Id`)
|
||||||
|
.orWhere(`note.${user}Host IS NULL`) // local
|
||||||
|
.orWhere(nonBlockedHostQuery(`note.${user}Host`)));
|
||||||
|
|
||||||
|
q
|
||||||
|
.andWhere(instanceSuspension('replyUser'))
|
||||||
|
.andWhere(instanceSuspension('renoteUser'));
|
||||||
|
} else {
|
||||||
|
const instanceSuspension = (user: string) => new Brackets(qb => qb
|
||||||
|
.where(`note.${user}Id IS NULL`) // no corresponding user
|
||||||
|
.orWhere(`note.${user}Host IS NULL`) // local
|
||||||
|
.orWhere(nonBlockedHostQuery(`note.${user}Host`)));
|
||||||
|
|
||||||
|
q
|
||||||
|
.andWhere(instanceSuspension('user'))
|
||||||
|
.andWhere(instanceSuspension('replyUser'))
|
||||||
|
.andWhere(instanceSuspension('renoteUser'));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,6 +234,7 @@ export class SearchService {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.queryService.generateVisibilityQuery(query, me);
|
this.queryService.generateVisibilityQuery(query, me);
|
||||||
|
this.queryService.generateBlockedHostQueryForNote(query);
|
||||||
if (me) this.queryService.generateMutedUserQueryForNotes(query, me);
|
if (me) this.queryService.generateMutedUserQueryForNotes(query, me);
|
||||||
if (me) this.queryService.generateBlockedUserQueryForNotes(query, me);
|
if (me) this.queryService.generateBlockedUserQueryForNotes(query, me);
|
||||||
|
|
||||||
|
@ -295,9 +296,14 @@ export class SearchService {
|
||||||
this.cacheService.userBlockedCache.fetch(me.id),
|
this.cacheService.userBlockedCache.fetch(me.id),
|
||||||
])
|
])
|
||||||
: [new Set<string>(), new Set<string>()];
|
: [new Set<string>(), new Set<string>()];
|
||||||
const notes = (await this.notesRepository.findBy({
|
|
||||||
id: In(res.hits.map(x => x.id)),
|
const query = this.notesRepository.createQueryBuilder('note');
|
||||||
})).filter(note => {
|
|
||||||
|
query.where('note.id IN (:...noteIds)', { noteIds: res.hits.map(x => x.id) });
|
||||||
|
|
||||||
|
this.queryService.generateBlockedHostQueryForNote(query);
|
||||||
|
|
||||||
|
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, userIdsWhoMeMuting)) return false;
|
if (me && isUserRelated(note, userIdsWhoMeMuting)) return false;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -111,6 +111,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
// NOTE: センシティブ除外の設定はこのエンドポイントでは無視する。
|
// NOTE: センシティブ除外の設定はこのエンドポイントでは無視する。
|
||||||
// https://github.com/misskey-dev/misskey/pull/15346#discussion_r1929950255
|
// https://github.com/misskey-dev/misskey/pull/15346#discussion_r1929950255
|
||||||
|
|
||||||
|
this.queryService.generateBlockedHostQueryForNote(query);
|
||||||
this.queryService.generateVisibilityQuery(query, me);
|
this.queryService.generateVisibilityQuery(query, me);
|
||||||
this.queryService.generateMutedUserQueryForNotes(query, me);
|
this.queryService.generateMutedUserQueryForNotes(query, me);
|
||||||
this.queryService.generateBlockedUserQueryForNotes(query, me);
|
this.queryService.generateBlockedUserQueryForNotes(query, me);
|
||||||
|
|
|
@ -121,6 +121,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
.leftJoinAndSelect('renote.user', 'renoteUser')
|
.leftJoinAndSelect('renote.user', 'renoteUser')
|
||||||
.leftJoinAndSelect('note.channel', 'channel');
|
.leftJoinAndSelect('note.channel', 'channel');
|
||||||
|
|
||||||
|
this.queryService.generateBlockedHostQueryForNote(query);
|
||||||
if (me) {
|
if (me) {
|
||||||
this.queryService.generateMutedUserQueryForNotes(query, me);
|
this.queryService.generateMutedUserQueryForNotes(query, me);
|
||||||
this.queryService.generateBlockedUserQueryForNotes(query, me);
|
this.queryService.generateBlockedUserQueryForNotes(query, me);
|
||||||
|
|
|
@ -85,6 +85,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
.leftJoinAndSelect('renote.user', 'renoteUser')
|
.leftJoinAndSelect('renote.user', 'renoteUser')
|
||||||
.andWhere('clipNote.clipId = :clipId', { clipId: clip.id });
|
.andWhere('clipNote.clipId = :clipId', { clipId: clip.id });
|
||||||
|
|
||||||
|
this.queryService.generateBlockedHostQueryForNote(query);
|
||||||
if (me) {
|
if (me) {
|
||||||
this.queryService.generateVisibilityQuery(query, me);
|
this.queryService.generateVisibilityQuery(query, me);
|
||||||
this.queryService.generateMutedUserQueryForNotes(query, me);
|
this.queryService.generateMutedUserQueryForNotes(query, me);
|
||||||
|
|
|
@ -70,6 +70,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
.leftJoinAndSelect('renote.user', 'renoteUser');
|
.leftJoinAndSelect('renote.user', 'renoteUser');
|
||||||
|
|
||||||
this.queryService.generateVisibilityQuery(query, me);
|
this.queryService.generateVisibilityQuery(query, me);
|
||||||
|
this.queryService.generateBlockedHostQueryForNote(query);
|
||||||
if (me) {
|
if (me) {
|
||||||
this.queryService.generateMutedUserQueryForNotes(query, me);
|
this.queryService.generateMutedUserQueryForNotes(query, me);
|
||||||
this.queryService.generateBlockedUserQueryForNotes(query, me);
|
this.queryService.generateBlockedUserQueryForNotes(query, me);
|
||||||
|
|
|
@ -11,6 +11,7 @@ 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 { CacheService } from '@/core/CacheService.js';
|
import { CacheService } from '@/core/CacheService.js';
|
||||||
|
import { QueryService } from '@/core/QueryService.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['notes'],
|
tags: ['notes'],
|
||||||
|
@ -52,6 +53,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
private cacheService: CacheService,
|
private cacheService: CacheService,
|
||||||
private noteEntityService: NoteEntityService,
|
private noteEntityService: NoteEntityService,
|
||||||
private featuredService: FeaturedService,
|
private featuredService: FeaturedService,
|
||||||
|
private queryService: QueryService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
let noteIds: string[];
|
let noteIds: string[];
|
||||||
|
@ -94,6 +96,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
.leftJoinAndSelect('renote.user', 'renoteUser')
|
.leftJoinAndSelect('renote.user', 'renoteUser')
|
||||||
.leftJoinAndSelect('note.channel', 'channel');
|
.leftJoinAndSelect('note.channel', 'channel');
|
||||||
|
|
||||||
|
this.queryService.generateBlockedHostQueryForNote(query);
|
||||||
|
|
||||||
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, userIdsWhoMeMuting)) return false;
|
if (me && isUserRelated(note, userIdsWhoMeMuting)) return false;
|
||||||
|
|
|
@ -243,6 +243,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
}
|
}
|
||||||
|
|
||||||
this.queryService.generateVisibilityQuery(query, me);
|
this.queryService.generateVisibilityQuery(query, me);
|
||||||
|
this.queryService.generateBlockedHostQueryForNote(query);
|
||||||
this.queryService.generateMutedUserQueryForNotes(query, me);
|
this.queryService.generateMutedUserQueryForNotes(query, me);
|
||||||
this.queryService.generateBlockedUserQueryForNotes(query, me);
|
this.queryService.generateBlockedUserQueryForNotes(query, me);
|
||||||
this.queryService.generateMutedUserRenotesQueryForNotes(query, me);
|
this.queryService.generateMutedUserRenotesQueryForNotes(query, me);
|
||||||
|
|
|
@ -156,6 +156,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
.leftJoinAndSelect('renote.user', 'renoteUser');
|
.leftJoinAndSelect('renote.user', 'renoteUser');
|
||||||
|
|
||||||
this.queryService.generateVisibilityQuery(query, me);
|
this.queryService.generateVisibilityQuery(query, me);
|
||||||
|
this.queryService.generateBlockedHostQueryForNote(query);
|
||||||
if (me) this.queryService.generateMutedUserQueryForNotes(query, me);
|
if (me) this.queryService.generateMutedUserQueryForNotes(query, me);
|
||||||
if (me) this.queryService.generateBlockedUserQueryForNotes(query, me);
|
if (me) this.queryService.generateBlockedUserQueryForNotes(query, me);
|
||||||
if (me) this.queryService.generateMutedUserRenotesQueryForNotes(query, me);
|
if (me) this.queryService.generateMutedUserRenotesQueryForNotes(query, me);
|
||||||
|
|
|
@ -72,6 +72,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
.leftJoinAndSelect('renote.user', 'renoteUser');
|
.leftJoinAndSelect('renote.user', 'renoteUser');
|
||||||
|
|
||||||
this.queryService.generateVisibilityQuery(query, me);
|
this.queryService.generateVisibilityQuery(query, me);
|
||||||
|
this.queryService.generateBlockedHostQueryForNote(query);
|
||||||
this.queryService.generateMutedUserQueryForNotes(query, me);
|
this.queryService.generateMutedUserQueryForNotes(query, me);
|
||||||
this.queryService.generateMutedNoteThreadQuery(query, me);
|
this.queryService.generateMutedNoteThreadQuery(query, me);
|
||||||
this.queryService.generateBlockedUserQueryForNotes(query, me);
|
this.queryService.generateBlockedUserQueryForNotes(query, me);
|
||||||
|
|
|
@ -72,6 +72,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
.leftJoinAndSelect('renote.user', 'renoteUser');
|
.leftJoinAndSelect('renote.user', 'renoteUser');
|
||||||
|
|
||||||
this.queryService.generateVisibilityQuery(query, me);
|
this.queryService.generateVisibilityQuery(query, me);
|
||||||
|
this.queryService.generateBlockedHostQueryForNote(query);
|
||||||
if (me) this.queryService.generateMutedUserQueryForNotes(query, me);
|
if (me) this.queryService.generateMutedUserQueryForNotes(query, me);
|
||||||
if (me) this.queryService.generateBlockedUserQueryForNotes(query, me);
|
if (me) this.queryService.generateBlockedUserQueryForNotes(query, me);
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
.leftJoinAndSelect('renote.user', 'renoteUser');
|
.leftJoinAndSelect('renote.user', 'renoteUser');
|
||||||
|
|
||||||
this.queryService.generateVisibilityQuery(query, me);
|
this.queryService.generateVisibilityQuery(query, me);
|
||||||
|
this.queryService.generateBlockedHostQueryForNote(query);
|
||||||
if (me) this.queryService.generateMutedUserQueryForNotes(query, me);
|
if (me) this.queryService.generateMutedUserQueryForNotes(query, me);
|
||||||
if (me) this.queryService.generateBlockedUserQueryForNotes(query, me);
|
if (me) this.queryService.generateBlockedUserQueryForNotes(query, me);
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
.leftJoinAndSelect('renote.user', 'renoteUser');
|
.leftJoinAndSelect('renote.user', 'renoteUser');
|
||||||
|
|
||||||
this.queryService.generateVisibilityQuery(query, me);
|
this.queryService.generateVisibilityQuery(query, me);
|
||||||
|
this.queryService.generateBlockedHostQueryForNote(query);
|
||||||
if (me) this.queryService.generateMutedUserQueryForNotes(query, me);
|
if (me) this.queryService.generateMutedUserQueryForNotes(query, me);
|
||||||
if (me) this.queryService.generateBlockedUserQueryForNotes(query, me);
|
if (me) this.queryService.generateBlockedUserQueryForNotes(query, me);
|
||||||
|
|
||||||
|
|
|
@ -199,6 +199,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this.queryService.generateVisibilityQuery(query, me);
|
this.queryService.generateVisibilityQuery(query, me);
|
||||||
|
this.queryService.generateBlockedHostQueryForNote(query);
|
||||||
this.queryService.generateMutedUserQueryForNotes(query, me);
|
this.queryService.generateMutedUserQueryForNotes(query, me);
|
||||||
this.queryService.generateBlockedUserQueryForNotes(query, me);
|
this.queryService.generateBlockedUserQueryForNotes(query, me);
|
||||||
this.queryService.generateMutedUserRenotesQueryForNotes(query, me);
|
this.queryService.generateMutedUserRenotesQueryForNotes(query, me);
|
||||||
|
|
|
@ -184,6 +184,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this.queryService.generateVisibilityQuery(query, me);
|
this.queryService.generateVisibilityQuery(query, me);
|
||||||
|
this.queryService.generateBlockedHostQueryForNote(query);
|
||||||
this.queryService.generateMutedUserQueryForNotes(query, me);
|
this.queryService.generateMutedUserQueryForNotes(query, me);
|
||||||
this.queryService.generateBlockedUserQueryForNotes(query, me);
|
this.queryService.generateBlockedUserQueryForNotes(query, me);
|
||||||
this.queryService.generateMutedUserRenotesQueryForNotes(query, me);
|
this.queryService.generateMutedUserRenotesQueryForNotes(query, me);
|
||||||
|
|
|
@ -102,6 +102,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
.leftJoinAndSelect('renote.user', 'renoteUser');
|
.leftJoinAndSelect('renote.user', 'renoteUser');
|
||||||
|
|
||||||
this.queryService.generateVisibilityQuery(query, me);
|
this.queryService.generateVisibilityQuery(query, me);
|
||||||
|
this.queryService.generateBlockedHostQueryForNote(query);
|
||||||
this.queryService.generateMutedUserQueryForNotes(query, me);
|
this.queryService.generateMutedUserQueryForNotes(query, me);
|
||||||
this.queryService.generateBlockedUserQueryForNotes(query, me);
|
this.queryService.generateBlockedUserQueryForNotes(query, me);
|
||||||
|
|
||||||
|
|
|
@ -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 { QueryService } from '@/core/QueryService.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['notes'],
|
tags: ['notes'],
|
||||||
|
@ -49,6 +50,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
private noteEntityService: NoteEntityService,
|
private noteEntityService: NoteEntityService,
|
||||||
private featuredService: FeaturedService,
|
private featuredService: FeaturedService,
|
||||||
private cacheService: CacheService,
|
private cacheService: CacheService,
|
||||||
|
private queryService: QueryService,
|
||||||
) {
|
) {
|
||||||
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>();
|
||||||
|
@ -85,6 +87,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
.leftJoinAndSelect('renote.user', 'renoteUser')
|
.leftJoinAndSelect('renote.user', 'renoteUser')
|
||||||
.leftJoinAndSelect('note.channel', 'channel');
|
.leftJoinAndSelect('note.channel', 'channel');
|
||||||
|
|
||||||
|
this.queryService.generateBlockedHostQueryForNote(query);
|
||||||
|
|
||||||
const notes = (await query.getMany()).filter(note => {
|
const notes = (await query.getMany()).filter(note => {
|
||||||
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;
|
||||||
|
|
|
@ -129,6 +129,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
redisTimelines,
|
redisTimelines,
|
||||||
useDbFallback: true,
|
useDbFallback: true,
|
||||||
ignoreAuthorFromMute: true,
|
ignoreAuthorFromMute: true,
|
||||||
|
ignoreAuthorFromInstanceBlock: true,
|
||||||
excludeReplies: ps.withChannelNotes && !ps.withReplies, // userTimelineWithChannel may include replies
|
excludeReplies: ps.withChannelNotes && !ps.withReplies, // userTimelineWithChannel may include replies
|
||||||
excludeNoFiles: ps.withChannelNotes && ps.withFiles, // userTimelineWithChannel may include notes without files
|
excludeNoFiles: ps.withChannelNotes && ps.withFiles, // userTimelineWithChannel may include notes without files
|
||||||
excludePureRenotes: !ps.withRenotes,
|
excludePureRenotes: !ps.withRenotes,
|
||||||
|
@ -184,6 +185,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
}
|
}
|
||||||
|
|
||||||
this.queryService.generateVisibilityQuery(query, me);
|
this.queryService.generateVisibilityQuery(query, me);
|
||||||
|
this.queryService.generateBlockedHostQueryForNote(query, true);
|
||||||
if (me) {
|
if (me) {
|
||||||
this.queryService.generateMutedUserQueryForNotes(query, me, { id: ps.userId });
|
this.queryService.generateMutedUserQueryForNotes(query, me, { id: ps.userId });
|
||||||
this.queryService.generateBlockedUserQueryForNotes(query, me);
|
this.queryService.generateBlockedUserQueryForNotes(query, me);
|
||||||
|
|
|
@ -102,6 +102,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
.leftJoinAndSelect('reaction.note', 'note');
|
.leftJoinAndSelect('reaction.note', 'note');
|
||||||
|
|
||||||
this.queryService.generateVisibilityQuery(query, me);
|
this.queryService.generateVisibilityQuery(query, me);
|
||||||
|
this.queryService.generateBlockedHostQueryForNote(query);
|
||||||
|
|
||||||
const reactions = (await query
|
const reactions = (await query
|
||||||
.limit(ps.limit)
|
.limit(ps.limit)
|
||||||
|
|
Loading…
Reference in New Issue