fix: クエリとか修正
This commit is contained in:
parent
ac95b12f0b
commit
fd9b7edeff
|
@ -11,6 +11,7 @@ import type { UserProfilesRepository, FollowingsRepository, ChannelFollowingsRep
|
||||||
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';
|
||||||
|
import {MiBlockingType} from "@/models/_.js";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class QueryService {
|
export class QueryService {
|
||||||
|
@ -73,7 +74,7 @@ export class QueryService {
|
||||||
const blockingQuery = this.blockingsRepository.createQueryBuilder('blocking')
|
const blockingQuery = this.blockingsRepository.createQueryBuilder('blocking')
|
||||||
.select('blocking.blockerId')
|
.select('blocking.blockerId')
|
||||||
.where('blocking.blockeeId = :blockeeId', { blockeeId: me.id })
|
.where('blocking.blockeeId = :blockeeId', { blockeeId: me.id })
|
||||||
.andWhere('blocking.blockType = "user"');
|
.andWhere('blocking.blockType = :blockType', { blockType: MiBlockingType.User });
|
||||||
|
|
||||||
// 投稿の作者にブロックされていない かつ
|
// 投稿の作者にブロックされていない かつ
|
||||||
// 投稿の返信先の作者にブロックされていない かつ
|
// 投稿の返信先の作者にブロックされていない かつ
|
||||||
|
@ -99,7 +100,7 @@ export class QueryService {
|
||||||
const blockingQuery = this.blockingsRepository.createQueryBuilder('blocking')
|
const blockingQuery = this.blockingsRepository.createQueryBuilder('blocking')
|
||||||
.select('blocking.blockeeId')
|
.select('blocking.blockeeId')
|
||||||
.where('blocking.blockerId = :blockerId', { blockerId: me.id })
|
.where('blocking.blockerId = :blockerId', { blockerId: me.id })
|
||||||
.andWhere('blocking.blockType = "user"');
|
.andWhere('blocking.blockType = :blockType', { blockType: MiBlockingType.User });
|
||||||
|
|
||||||
const blockedQuery = this.blockingsRepository.createQueryBuilder('blocking')
|
const blockedQuery = this.blockingsRepository.createQueryBuilder('blocking')
|
||||||
.select('blocking.blockerId')
|
.select('blocking.blockerId')
|
||||||
|
|
|
@ -291,25 +291,25 @@ export class UserEntityService implements OnModuleInit {
|
||||||
this.blockingsRepository.createQueryBuilder('b')
|
this.blockingsRepository.createQueryBuilder('b')
|
||||||
.select('b.blockeeId')
|
.select('b.blockeeId')
|
||||||
.where('b.blockerId = :me', { me })
|
.where('b.blockerId = :me', { me })
|
||||||
.andWhere('b.blockType = "user"')
|
.andWhere('b.blockType = :type', { type: MiBlockingType.User })
|
||||||
.getRawMany<{ b_blockeeId: string }>()
|
.getRawMany<{ b_blockeeId: string }>()
|
||||||
.then(it => it.map(it => it.b_blockeeId)),
|
.then(it => it.map(it => it.b_blockeeId)),
|
||||||
this.blockingsRepository.createQueryBuilder('b')
|
this.blockingsRepository.createQueryBuilder('b')
|
||||||
.select('b.blockerId')
|
.select('b.blockerId')
|
||||||
.where('b.blockeeId = :me', { me })
|
.where('b.blockeeId = :me', { me })
|
||||||
.andWhere('b.blockType = "user"')
|
.andWhere('b.blockType = :type', { type: MiBlockingType.User })
|
||||||
.getRawMany<{ b_blockerId: string }>()
|
.getRawMany<{ b_blockerId: string }>()
|
||||||
.then(it => it.map(it => it.b_blockerId)),
|
.then(it => it.map(it => it.b_blockerId)),
|
||||||
this.blockingsRepository.createQueryBuilder('b')
|
this.blockingsRepository.createQueryBuilder('b')
|
||||||
.select('b.blockeeId')
|
.select('b.blockeeId')
|
||||||
.where('b.blockerId = :me', { me })
|
.where('b.blockerId = :me', { me })
|
||||||
.andWhere('b.blockType = "reaction"')
|
.andWhere('b.blockType = :type', { type: MiBlockingType.Reaction })
|
||||||
.getRawMany<{ b_blockeeId: string }>()
|
.getRawMany<{ b_blockeeId: string }>()
|
||||||
.then(it => it.map(it => it.b_blockeeId)),
|
.then(it => it.map(it => it.b_blockeeId)),
|
||||||
this.blockingsRepository.createQueryBuilder('b')
|
this.blockingsRepository.createQueryBuilder('b')
|
||||||
.select('b.blockerId')
|
.select('b.blockerId')
|
||||||
.where('b.blockeeId = :me', { me })
|
.where('b.blockeeId = :me', { me })
|
||||||
.andWhere('b.blockType = "reaction"')
|
.andWhere('b.blockType = :type', { type: MiBlockingType.Reaction })
|
||||||
.getRawMany<{ b_blockerId: string }>()
|
.getRawMany<{ b_blockerId: string }>()
|
||||||
.then(it => it.map(it => it.b_blockerId)),
|
.then(it => it.map(it => it.b_blockerId)),
|
||||||
this.mutingsRepository.createQueryBuilder('m')
|
this.mutingsRepository.createQueryBuilder('m')
|
||||||
|
|
|
@ -9,6 +9,7 @@ import type { BlockingsRepository } from '@/models/_.js';
|
||||||
import { QueryService } from '@/core/QueryService.js';
|
import { QueryService } from '@/core/QueryService.js';
|
||||||
import { BlockingEntityService } from '@/core/entities/BlockingEntityService.js';
|
import { BlockingEntityService } from '@/core/entities/BlockingEntityService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
|
import { MiBlockingType } from '@/models/Blocking.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['account'],
|
tags: ['account'],
|
||||||
|
@ -50,7 +51,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
const query = this.queryService.makePaginationQuery(this.blockingsRepository.createQueryBuilder('blocking'), ps.sinceId, ps.untilId)
|
const query = this.queryService.makePaginationQuery(this.blockingsRepository.createQueryBuilder('blocking'), ps.sinceId, ps.untilId)
|
||||||
.andWhere('blocking.blockerId = :meId', { meId: me.id })
|
.andWhere('blocking.blockerId = :meId', { meId: me.id })
|
||||||
.andWhere('blocking.blockType = "reaction"');
|
.andWhere('blocking.blockType = :blockType', { blockType: MiBlockingType.Reaction });
|
||||||
|
|
||||||
const blockings = await query
|
const blockings = await query
|
||||||
.limit(ps.limit)
|
.limit(ps.limit)
|
||||||
|
|
|
@ -9,6 +9,7 @@ import type { BlockingsRepository } from '@/models/_.js';
|
||||||
import { QueryService } from '@/core/QueryService.js';
|
import { QueryService } from '@/core/QueryService.js';
|
||||||
import { BlockingEntityService } from '@/core/entities/BlockingEntityService.js';
|
import { BlockingEntityService } from '@/core/entities/BlockingEntityService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
|
import { MiBlockingType } from '@/models/Blocking.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['account'],
|
tags: ['account'],
|
||||||
|
@ -50,7 +51,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
const query = this.queryService.makePaginationQuery(this.blockingsRepository.createQueryBuilder('blocking'), ps.sinceId, ps.untilId)
|
const query = this.queryService.makePaginationQuery(this.blockingsRepository.createQueryBuilder('blocking'), ps.sinceId, ps.untilId)
|
||||||
.andWhere('blocking.blockerId = :meId', { meId: me.id })
|
.andWhere('blocking.blockerId = :meId', { meId: me.id })
|
||||||
.andWhere('blocking.blockType = "user"');
|
.andWhere('blocking.blockType = :blockType', { blockType: MiBlockingType.User });
|
||||||
|
|
||||||
const blockings = await query
|
const blockings = await query
|
||||||
.limit(ps.limit)
|
.limit(ps.limit)
|
||||||
|
|
|
@ -12,7 +12,7 @@ import { secureRndstr } from '@/misc/secure-rndstr.js';
|
||||||
import { genAidx } from '@/misc/id/aidx.js';
|
import { genAidx } from '@/misc/id/aidx.js';
|
||||||
import {
|
import {
|
||||||
BlockingsRepository,
|
BlockingsRepository,
|
||||||
FollowingsRepository, FollowRequestsRepository,
|
FollowingsRepository, FollowRequestsRepository, MiBlockingType,
|
||||||
MiUserProfile, MutingsRepository, RenoteMutingsRepository,
|
MiUserProfile, MutingsRepository, RenoteMutingsRepository,
|
||||||
UserMemoRepository,
|
UserMemoRepository,
|
||||||
UserProfilesRepository,
|
UserProfilesRepository,
|
||||||
|
@ -115,7 +115,7 @@ describe('UserEntityService', () => {
|
||||||
id: genAidx(Date.now()),
|
id: genAidx(Date.now()),
|
||||||
blockerId: blocker.id,
|
blockerId: blocker.id,
|
||||||
blockeeId: blockee.id,
|
blockeeId: blockee.id,
|
||||||
isReactionBlock: false,
|
blockType: MiBlockingType.User,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ describe('UserEntityService', () => {
|
||||||
id: genAidx(Date.now()),
|
id: genAidx(Date.now()),
|
||||||
blockerId: blocker.id,
|
blockerId: blocker.id,
|
||||||
blockeeId: blockee.id,
|
blockeeId: blockee.id,
|
||||||
isReactionBlock: true,
|
blockType: MiBlockingType.Reaction,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue