mirror of
https://github.com/paricafe/misskey.git
synced 2024-12-01 22:56:43 -06:00
d071d18dd7
* wip * wip * fix * clean up * Update tsconfig.json * Update activitypub.ts * wip
27 lines
1.1 KiB
TypeScript
27 lines
1.1 KiB
TypeScript
import { User } from '@/models/entities/user.js';
|
|
import { Brackets, SelectQueryBuilder } from 'typeorm';
|
|
|
|
export function generateRepliesQuery(q: SelectQueryBuilder<any>, me?: Pick<User, 'id' | 'showTimelineReplies'> | null) {
|
|
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 if (!me.showTimelineReplies) {
|
|
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');
|
|
}));
|
|
}));
|
|
}
|
|
}
|