TLの抽出条件調節
This commit is contained in:
parent
ae485ed568
commit
a56c680136
|
@ -5,7 +5,7 @@
|
|||
|
||||
import { Brackets } from 'typeorm';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import type { NotesRepository, ChannelFollowingsRepository } from '@/models/_.js';
|
||||
import type { ChannelFollowingsRepository, NotesRepository } from '@/models/_.js';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import ActiveUsersChart from '@/core/chart/charts/active-users.js';
|
||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||
|
@ -77,10 +77,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
constructor(
|
||||
@Inject(DI.notesRepository)
|
||||
private notesRepository: NotesRepository,
|
||||
|
||||
@Inject(DI.channelFollowingsRepository)
|
||||
private channelFollowingsRepository: ChannelFollowingsRepository,
|
||||
|
||||
private noteEntityService: NoteEntityService,
|
||||
private roleService: RoleService,
|
||||
private activeUsersChart: ActiveUsersChart,
|
||||
|
@ -191,9 +189,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
followerId: me.id,
|
||||
},
|
||||
});
|
||||
const mutingChannelIds = (followingChannels.length > 0)
|
||||
? await this.channelMutingService.list({ requestUserId: me.id }).then(x => x.map(x => x.id))
|
||||
: [];
|
||||
const mutingChannelIds = await this.channelMutingService.list({ requestUserId: me.id }).then(x => x.map(x => x.id));
|
||||
|
||||
const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId)
|
||||
.andWhere(new Brackets(qb => {
|
||||
|
@ -224,12 +220,25 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
}
|
||||
|
||||
if (mutingChannelIds.length > 0) {
|
||||
// ミュートしてるチャンネルは含めない
|
||||
query.andWhere(new Brackets(qb => {
|
||||
qb
|
||||
.andWhere('note.channelId NOT IN (:...mutingChannelIds)', { mutingChannelIds })
|
||||
// ミュートしてるチャンネルは含めない
|
||||
.where(new Brackets(qb2 => {
|
||||
qb2
|
||||
.andWhere(new Brackets(qb3 => {
|
||||
qb3
|
||||
.andWhere('note.channelId IS NOT NULL')
|
||||
.andWhere('note.channelId NOT IN (:...mutingChannelIds)', { mutingChannelIds });
|
||||
}))
|
||||
.andWhere(new Brackets(qb3 => {
|
||||
qb3
|
||||
.andWhere('note.renoteChannelId IS NOT NULL')
|
||||
.andWhere('note.renoteChannelId NOT IN (:...mutingChannelIds)', { mutingChannelIds });
|
||||
}));
|
||||
}))
|
||||
// チャンネルの投稿ではない
|
||||
.orWhere('note.channelId IS NULL');
|
||||
}));
|
||||
}
|
||||
|
||||
if (!ps.withReplies) {
|
||||
|
|
|
@ -149,9 +149,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
followerId: me.id,
|
||||
},
|
||||
});
|
||||
const mutingChannelIds = (followingChannels.length > 0)
|
||||
? await this.channelMutingService.list({ requestUserId: me.id }).then(x => x.map(x => x.id))
|
||||
: [];
|
||||
const mutingChannelIds = await this.channelMutingService.list({ requestUserId: me.id }).then(x => x.map(x => x.id));
|
||||
|
||||
//#region Construct query
|
||||
const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId)
|
||||
|
@ -200,12 +198,25 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
}
|
||||
|
||||
if (mutingChannelIds.length > 0) {
|
||||
// ミュートしてるチャンネルは含めない
|
||||
query.andWhere(new Brackets(qb => {
|
||||
qb
|
||||
.andWhere('note.channelId NOT IN (:...mutingChannelIds)', { mutingChannelIds })
|
||||
// ミュートしてるチャンネルは含めない
|
||||
.where(new Brackets(qb2 => {
|
||||
qb2
|
||||
.andWhere(new Brackets(qb3 => {
|
||||
qb3
|
||||
.andWhere('note.channelId IS NOT NULL')
|
||||
.andWhere('note.channelId NOT IN (:...mutingChannelIds)', { mutingChannelIds });
|
||||
}))
|
||||
.andWhere(new Brackets(qb3 => {
|
||||
qb3
|
||||
.andWhere('note.renoteChannelId IS NOT NULL')
|
||||
.andWhere('note.renoteChannelId NOT IN (:...mutingChannelIds)', { mutingChannelIds });
|
||||
}));
|
||||
}))
|
||||
// チャンネルの投稿ではない
|
||||
.orWhere('note.channelId IS NULL');
|
||||
}));
|
||||
}
|
||||
|
||||
query.andWhere(new Brackets(qb => {
|
||||
|
|
Loading…
Reference in a new issue