mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-23 02:17:40 -07:00
Fix #5950
This commit is contained in:
parent
cff0d71fef
commit
3b7b2e8314
5 changed files with 35 additions and 49 deletions
27
src/server/api/common/generate-replies-query.ts
Normal file
27
src/server/api/common/generate-replies-query.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import { User } from '../../../models/entities/user';
|
||||
import { Brackets, SelectQueryBuilder } from 'typeorm';
|
||||
|
||||
export function generateRepliesQuery(q: SelectQueryBuilder<any>, me?: User) {
|
||||
if (me == null) {
|
||||
q.andWhere(new Brackets(qb => { qb
|
||||
.where(`note.replyId IS NULL`) // 返信ではない
|
||||
.orWhere(new Brackets(qb => { qb // 返信だけど投稿者自身への返信
|
||||
.where(`note.replyId IS NOT NULL`)
|
||||
.andWhere('note.replyUserId = note.userId');
|
||||
}));
|
||||
}));
|
||||
} else {
|
||||
q.andWhere(new Brackets(qb => { qb
|
||||
.where(`note.replyId IS NULL`) // 返信ではない
|
||||
.orWhere('note.replyUserId = :meId', { meId: me.id }) // 返信だけど自分のノートへの返信
|
||||
.orWhere(new Brackets(qb => { qb // 返信だけど自分の行った返信
|
||||
.where(`note.replyId IS NOT NULL`)
|
||||
.andWhere('note.userId = :meId', { meId: me.id });
|
||||
}))
|
||||
.orWhere(new Brackets(qb => { qb // 返信だけど投稿者自身への返信
|
||||
.where(`note.replyId IS NOT NULL`)
|
||||
.andWhere('note.replyUserId = note.userId');
|
||||
}));
|
||||
}));
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ import { Notes } from '../../../../models';
|
|||
import { generateMuteQuery } from '../../common/generate-mute-query';
|
||||
import { activeUsersChart } from '../../../../services/chart';
|
||||
import { Brackets } from 'typeorm';
|
||||
import { generateRepliesQuery } from '../../common/generate-replies-query';
|
||||
|
||||
export const meta = {
|
||||
desc: {
|
||||
|
@ -77,21 +78,9 @@ export default define(meta, async (ps, user) => {
|
|||
const query = makePaginationQuery(Notes.createQueryBuilder('note'),
|
||||
ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
|
||||
.andWhere('note.visibility = \'public\'')
|
||||
.andWhere('note.replyId IS NULL')
|
||||
.andWhere(new Brackets(qb => { qb
|
||||
.where(`note.replyId IS NULL`) // 返信ではない
|
||||
.orWhere('note.replyUserId = :meId', { meId: user.id }) // 返信だけど自分のノートへの返信
|
||||
.orWhere(new Brackets(qb => { qb // 返信だけど自分の行った返信
|
||||
.where(`note.replyId IS NOT NULL`)
|
||||
.andWhere('note.userId = :meId', { meId: user.id });
|
||||
}))
|
||||
.orWhere(new Brackets(qb => { qb // 返信だけど投稿者自身への返信
|
||||
.where(`note.replyId IS NOT NULL`)
|
||||
.andWhere('note.replyUserId = note.userId', { meId: user.id });
|
||||
}));
|
||||
}))
|
||||
.leftJoinAndSelect('note.user', 'user');
|
||||
|
||||
generateRepliesQuery(query, user);
|
||||
if (user) generateMuteQuery(query, user);
|
||||
|
||||
if (ps.withFiles) {
|
||||
|
|
|
@ -9,6 +9,7 @@ import { Brackets } from 'typeorm';
|
|||
import { generateVisibilityQuery } from '../../common/generate-visibility-query';
|
||||
import { generateMuteQuery } from '../../common/generate-mute-query';
|
||||
import { activeUsersChart } from '../../../../services/chart';
|
||||
import { generateRepliesQuery } from '../../common/generate-replies-query';
|
||||
|
||||
export const meta = {
|
||||
desc: {
|
||||
|
@ -124,21 +125,10 @@ export default define(meta, async (ps, user) => {
|
|||
qb.where(`((note.userId IN (${ followingQuery.getQuery() })) OR (note.userId = :meId))`, { meId: user.id })
|
||||
.orWhere('(note.visibility = \'public\') AND (note.userHost IS NULL)');
|
||||
}))
|
||||
.andWhere(new Brackets(qb => { qb
|
||||
.where(`note.replyId IS NULL`) // 返信ではない
|
||||
.orWhere('note.replyUserId = :meId', { meId: user.id }) // 返信だけど自分のノートへの返信
|
||||
.orWhere(new Brackets(qb => { qb // 返信だけど自分の行った返信
|
||||
.where(`note.replyId IS NOT NULL`)
|
||||
.andWhere('note.userId = :meId', { meId: user.id });
|
||||
}))
|
||||
.orWhere(new Brackets(qb => { qb // 返信だけど投稿者自身への返信
|
||||
.where(`note.replyId IS NOT NULL`)
|
||||
.andWhere('note.replyUserId = note.userId', { meId: user.id });
|
||||
}));
|
||||
}))
|
||||
.leftJoinAndSelect('note.user', 'user')
|
||||
.setParameters(followingQuery.getParameters());
|
||||
|
||||
generateRepliesQuery(query, user);
|
||||
generateVisibilityQuery(query, user);
|
||||
generateMuteQuery(query, user);
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query';
|
|||
import { generateVisibilityQuery } from '../../common/generate-visibility-query';
|
||||
import { activeUsersChart } from '../../../../services/chart';
|
||||
import { Brackets } from 'typeorm';
|
||||
import { generateRepliesQuery } from '../../common/generate-replies-query';
|
||||
|
||||
export const meta = {
|
||||
desc: {
|
||||
|
@ -93,20 +94,9 @@ export default define(meta, async (ps, user) => {
|
|||
const query = makePaginationQuery(Notes.createQueryBuilder('note'),
|
||||
ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
|
||||
.andWhere('(note.visibility = \'public\') AND (note.userHost IS NULL)')
|
||||
.andWhere(new Brackets(qb => { qb
|
||||
.where(`note.replyId IS NULL`) // 返信ではない
|
||||
.orWhere('note.replyUserId = :meId', { meId: user.id }) // 返信だけど自分のノートへの返信
|
||||
.orWhere(new Brackets(qb => { qb // 返信だけど自分の行った返信
|
||||
.where(`note.replyId IS NOT NULL`)
|
||||
.andWhere('note.userId = :meId', { meId: user.id });
|
||||
}))
|
||||
.orWhere(new Brackets(qb => { qb // 返信だけど投稿者自身への返信
|
||||
.where(`note.replyId IS NOT NULL`)
|
||||
.andWhere('note.replyUserId = note.userId', { meId: user.id });
|
||||
}));
|
||||
}))
|
||||
.leftJoinAndSelect('note.user', 'user');
|
||||
|
||||
generateRepliesQuery(query, user);
|
||||
generateVisibilityQuery(query, user);
|
||||
if (user) generateMuteQuery(query, user);
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import { generateVisibilityQuery } from '../../common/generate-visibility-query'
|
|||
import { generateMuteQuery } from '../../common/generate-mute-query';
|
||||
import { activeUsersChart } from '../../../../services/chart';
|
||||
import { Brackets } from 'typeorm';
|
||||
import { generateRepliesQuery } from '../../common/generate-replies-query';
|
||||
|
||||
export const meta = {
|
||||
desc: {
|
||||
|
@ -110,21 +111,10 @@ export default define(meta, async (ps, user) => {
|
|||
.where(`note.userId IN (${ followingQuery.getQuery() })`)
|
||||
.orWhere('note.userId = :meId', { meId: user.id });
|
||||
}))
|
||||
.andWhere(new Brackets(qb => { qb
|
||||
.where(`note.replyId IS NULL`) // 返信ではない
|
||||
.orWhere('note.replyUserId = :meId', { meId: user.id }) // 返信だけど自分のノートへの返信
|
||||
.orWhere(new Brackets(qb => { qb // 返信だけど自分の行った返信
|
||||
.where(`note.replyId IS NOT NULL`)
|
||||
.andWhere('note.userId = :meId', { meId: user.id });
|
||||
}))
|
||||
.orWhere(new Brackets(qb => { qb // 返信だけど投稿者自身への返信
|
||||
.where(`note.replyId IS NOT NULL`)
|
||||
.andWhere('note.replyUserId = note.userId', { meId: user.id });
|
||||
}));
|
||||
}))
|
||||
.leftJoinAndSelect('note.user', 'user')
|
||||
.setParameters(followingQuery.getParameters());
|
||||
|
||||
generateRepliesQuery(query, user);
|
||||
generateVisibilityQuery(query, user);
|
||||
generateMuteQuery(query, user);
|
||||
|
||||
|
|
Loading…
Reference in a new issue