From 1e737dbb94ac856be7cc68e834f99e0bb759cf41 Mon Sep 17 00:00:00 2001
From: ozelot <contact@ozelot.dev>
Date: Sat, 4 Nov 2023 18:45:59 +0900
Subject: [PATCH] =?UTF-8?q?fix(backend):=20GTL=E3=81=AE=E3=80=8C=E3=83=AA?=
 =?UTF-8?q?=E3=83=8E=E3=83=BC=E3=83=88=E3=82=92=E8=A1=A8=E7=A4=BA=E3=80=8D?=
 =?UTF-8?q?=E3=82=AA=E3=83=97=E3=82=B7=E3=83=A7=E3=83=B3=E3=81=8C=E6=A9=9F?=
 =?UTF-8?q?=E8=83=BD=E3=81=97=E3=81=AA=E3=81=84=E3=81=AE=E3=82=92=E4=BF=AE?=
 =?UTF-8?q?=E6=AD=A3=20(#12234)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* fix(backend): GTLの「リノートを表示」オプションが機能しないのを修正 (#12233)

* docs: Update changelog

* Apply suggestions from code review

Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>

---------

Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
---
 CHANGELOG.md                                           |  1 +
 .../src/server/api/endpoints/notes/global-timeline.ts  | 10 ++++++++++
 2 files changed, 11 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4038755124..9a10167418 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -80,6 +80,7 @@
 - Fix: アクセストークンを削除すると、通知が取得できなくなる場合がある問題を修正
 - Fix: 自身の宛先なしダイレクト投稿がストリーミングで流れてこない問題を修正
 - Fix: サーバーサイドからのテスト通知を正しく行えるように修正
+- Fix: GTLの「リノートを表示」オプションが機能しないのを修正 #12233
 
 ## 2023.10.2
 
diff --git a/packages/backend/src/server/api/endpoints/notes/global-timeline.ts b/packages/backend/src/server/api/endpoints/notes/global-timeline.ts
index be7557c213..68fefa5b58 100644
--- a/packages/backend/src/server/api/endpoints/notes/global-timeline.ts
+++ b/packages/backend/src/server/api/endpoints/notes/global-timeline.ts
@@ -87,6 +87,16 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
 			if (ps.withFiles) {
 				query.andWhere('note.fileIds != \'{}\'');
 			}
+
+			if (ps.withRenotes === false) {
+				query.andWhere(new Brackets(qb => {
+					qb.where('note.renoteId IS NULL');
+					qb.orWhere(new Brackets(qb => {
+						qb.where('note.text IS NOT NULL');
+						qb.orWhere('note.fileIds != \'{}\'');
+					}));
+				}));
+			}
 			//#endregion
 
 			const timeline = await query.limit(ps.limit).getMany();