1
0
forked from mirror/misskey
* fix #5060

* forgot ";" :p
This commit is contained in:
Oni-Men 2019-07-21 22:27:36 +09:00 committed by syuilo
parent 6fbf1cfc28
commit 8aeabf530c
2 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,19 @@
import { User } from '../../../models/entities/user';
import { Blockings } from '../../../models';
import { SelectQueryBuilder } from 'typeorm';
export function generateBlockQueryForUsers(q: SelectQueryBuilder<any>, me: User) {
const blockingQuery = Blockings.createQueryBuilder('blocking')
.select('blocking.blockeeId')
.where('blocking.blockerId = :blockerId', { blockerId: me.id });
const blockedQuery = Blockings.createQueryBuilder('blocking')
.select('blocking.blockerId')
.where('blocking.blockeeId = :blockeeId', { blockeeId: me.id });
q.andWhere(`user.id NOT IN (${ blockingQuery.getQuery() })`);
q.setParameters(blockingQuery.getParameters());
q.andWhere(`user.id NOT IN (${ blockedQuery.getQuery() })`);
q.setParameters(blockedQuery.getParameters());
}

View File

@ -3,6 +3,7 @@ import $ from 'cafy';
import define from '../../define'; import define from '../../define';
import { Users, Followings } from '../../../../models'; import { Users, Followings } from '../../../../models';
import { generateMuteQueryForUsers } from '../../common/generate-mute-query'; import { generateMuteQueryForUsers } from '../../common/generate-mute-query';
import { generateBlockQueryForUsers } from '../../common/generate-block-query';
export const meta = { export const meta = {
desc: { desc: {
@ -47,6 +48,7 @@ export default define(meta, async (ps, me) => {
.orderBy('user.followersCount', 'DESC'); .orderBy('user.followersCount', 'DESC');
generateMuteQueryForUsers(query, me); generateMuteQueryForUsers(query, me);
generateBlockQueryForUsers(query, me);
const followingQuery = Followings.createQueryBuilder('following') const followingQuery = Followings.createQueryBuilder('following')
.select('following.followeeId') .select('following.followeeId')