From f31f986d669e5f20de1f949331a5f06ad3359654 Mon Sep 17 00:00:00 2001
From: syuilo <syuilotan@yahoo.co.jp>
Date: Tue, 23 Apr 2019 02:50:59 +0900
Subject: [PATCH] Fix #4768

---
 .../api/stream/channels/global-timeline.ts    |  2 ++
 test/streaming.ts                             | 25 +++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/src/server/api/stream/channels/global-timeline.ts b/src/server/api/stream/channels/global-timeline.ts
index bfb7697ba7..3aaadc1a4a 100644
--- a/src/server/api/stream/channels/global-timeline.ts
+++ b/src/server/api/stream/channels/global-timeline.ts
@@ -22,6 +22,8 @@ export default class extends Channel {
 
 	@autobind
 	private async onNote(note: any) {
+		if (note.visibility !== 'public') return;
+
 		// リプライなら再pack
 		if (note.replyId != null) {
 			note.reply = await Notes.pack(note.replyId, this.user, {
diff --git a/test/streaming.ts b/test/streaming.ts
index 2dfede1380..6b9ef9cea5 100644
--- a/test/streaming.ts
+++ b/test/streaming.ts
@@ -594,6 +594,31 @@ describe('Streaming', () => {
 				text: 'foo'
 			});
 		}));
+
+		it('ホーム投稿は流れない', () => new Promise(async done => {
+			const alice = await signup({ username: 'alice' });
+			const bob = await signup({ username: 'bob' });
+
+			let fired = false;
+
+			const ws = await connectStream(alice, 'globalTimeline', ({ type, body }) => {
+				if (type == 'note') {
+					fired = true;
+				}
+			});
+
+			// ホーム投稿
+			post(bob, {
+				text: 'foo',
+				visibility: 'home'
+			});
+
+			setTimeout(() => {
+				assert.strictEqual(fired, false);
+				ws.close();
+				done();
+			}, 3000);
+		}));
 	});
 
 	describe('UserList Timeline', () => {