Exclude suspended users note from featured
This commit is contained in:
parent
3bdb23108a
commit
0cc08ff260
|
@ -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.generateSuspendedUserQueryForNote(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;
|
||||||
|
|
|
@ -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.generateSuspendedUserQueryForNote(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;
|
||||||
|
|
Loading…
Reference in New Issue