summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints/notes/timeline.ts
diff options
context:
space:
mode:
authorMeiMei <30769358+mei23@users.noreply.github.com>2019-08-27 03:24:35 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2019-08-27 03:24:35 +0900
commitab6a84cd45a266e97feee6a268495db8c161ce88 (patch)
treedbcbdb24b7643f06bae7c2d354ac2318a8db998e /src/server/api/endpoints/notes/timeline.ts
parentPrevent users from changing the disabled option (#5344) (diff)
downloadsharkey-ab6a84cd45a266e97feee6a268495db8c161ce88.tar.gz
sharkey-ab6a84cd45a266e97feee6a268495db8c161ce88.tar.bz2
sharkey-ab6a84cd45a266e97feee6a268495db8c161ce88.zip
未実装のTLのRenoteクエリを実装 (#5343)
* users/notes includeMyRenotes * other renotes * fix target user in users/notes * users/notesからv10から未実装でありえないオプションを削除 * users/notesのincludeMyRenotesの説明を修正 * remove needless anonymous checks
Diffstat (limited to 'src/server/api/endpoints/notes/timeline.ts')
-rw-r--r--src/server/api/endpoints/notes/timeline.ts67
1 files changed, 22 insertions, 45 deletions
diff --git a/src/server/api/endpoints/notes/timeline.ts b/src/server/api/endpoints/notes/timeline.ts
index 25876f655a..b2fb250c53 100644
--- a/src/server/api/endpoints/notes/timeline.ts
+++ b/src/server/api/endpoints/notes/timeline.ts
@@ -116,58 +116,35 @@ export default define(meta, async (ps, user) => {
generateVisibilityQuery(query, user);
generateMuteQuery(query, user);
- /* v11 TODO
- // MongoDBではトップレベルで否定ができないため、De Morganの法則を利用してクエリします。
- // つまり、「『自分の投稿かつRenote』ではない」を「『自分の投稿ではない』または『Renoteではない』」と表現します。
- // for details: https://en.wikipedia.org/wiki/De_Morgan%27s_laws
-
if (ps.includeMyRenotes === false) {
- query.$and.push({
- $or: [{
- userId: { $ne: user.id }
- }, {
- renoteId: null
- }, {
- text: { $ne: null }
- }, {
- fileIds: { $ne: [] }
- }, {
- poll: { $ne: null }
- }]
- });
+ query.andWhere(new Brackets(qb => {
+ qb.orWhere('note.userId != :meId', { meId: user.id });
+ qb.orWhere('note.renoteId IS NULL');
+ qb.orWhere('note.text IS NOT NULL');
+ qb.orWhere('note.fileIds != \'{}\'');
+ qb.orWhere('0 < (SELECT COUNT(*) FROM poll WHERE poll."noteId" = note.id)');
+ }));
}
if (ps.includeRenotedMyNotes === false) {
- query.$and.push({
- $or: [{
- '_renote.userId': { $ne: user.id }
- }, {
- renoteId: null
- }, {
- text: { $ne: null }
- }, {
- fileIds: { $ne: [] }
- }, {
- poll: { $ne: null }
- }]
- });
+ query.andWhere(new Brackets(qb => {
+ qb.orWhere('note.renoteUserId != :meId', { meId: user.id });
+ qb.orWhere('note.renoteId IS NULL');
+ qb.orWhere('note.text IS NOT NULL');
+ qb.orWhere('note.fileIds != \'{}\'');
+ qb.orWhere('0 < (SELECT COUNT(*) FROM poll WHERE poll."noteId" = note.id)');
+ }));
}
if (ps.includeLocalRenotes === false) {
- query.$and.push({
- $or: [{
- '_renote.user.host': { $ne: null }
- }, {
- renoteId: null
- }, {
- text: { $ne: null }
- }, {
- fileIds: { $ne: [] }
- }, {
- poll: { $ne: null }
- }]
- });
- }*/
+ query.andWhere(new Brackets(qb => {
+ qb.orWhere('note.renoteUserHost IS NOT NULL');
+ qb.orWhere('note.renoteId IS NULL');
+ qb.orWhere('note.text IS NOT NULL');
+ qb.orWhere('note.fileIds != \'{}\'');
+ qb.orWhere('0 < (SELECT COUNT(*) FROM poll WHERE poll."noteId" = note.id)');
+ }));
+ }
if (ps.withFiles) {
query.andWhere('note.fileIds != \'{}\'');