diff options
author | Thibaut Girka <thib@sitedethib.com> | 2019-01-08 18:33:43 +0100 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2020-07-06 21:12:06 +0200 |
commit | d973e110616c132f1d8df676e7039a57b9134537 (patch) | |
tree | 58b8eb44fe1ab4cb9edea65b2cb6d404bcb83f22 /streaming | |
parent | 94e09d309cb068ea92919767e40e655260ac43cb (diff) |
Add UI option to show local-only toots in public timeline
Diffstat (limited to 'streaming')
-rw-r--r-- | streaming/index.js | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/streaming/index.js b/streaming/index.js index e47fbdbf8..6e75a2e80 100644 --- a/streaming/index.js +++ b/streaming/index.js @@ -307,6 +307,7 @@ const startWorker = (workerId) => { const PUBLIC_ENDPOINTS = [ '/api/v1/streaming/public', + '/api/v1/streaming/public/allow_local_only', '/api/v1/streaming/public/local', '/api/v1/streaming/public/remote', '/api/v1/streaming/hashtag', @@ -362,7 +363,7 @@ const startWorker = (workerId) => { }); }; - const streamFrom = (ids, req, output, attachCloseHandler, needsFiltering = false, notificationOnly = false) => { + const streamFrom = (ids, req, output, attachCloseHandler, needsFiltering = false, notificationOnly = false, allowLocalOnly = false) => { const accountId = req.accountId || req.remoteAddress; const streamType = notificationOnly ? ' (notification)' : ''; @@ -393,7 +394,7 @@ const startWorker = (workerId) => { } // Only send local-only statuses to logged-in users - if (event === 'update' && payload.local_only && !req.accountId) { + if (event === 'update' && payload.local_only && !req.accountId || !allowLocalOnly) { log.silly(req.requestId, `Message ${payload.id} filtered because it was local-only`); return; } @@ -562,14 +563,16 @@ const startWorker = (workerId) => { const onlyMedia = req.query.only_media === '1' || req.query.only_media === 'true'; const channel = onlyMedia ? 'timeline:public:media' : 'timeline:public'; - streamFrom(channel, req, streamToHttp(req, res), streamHttpEnd(req), true); + const allowLocalOnly = req.query.allow_local_only === '1' || req.query.allow_local_only === 'true'; + + streamFrom(channel, req, streamToHttp(req, res), streamHttpEnd(req), true, false, allowLocalOnly); }); app.get('/api/v1/streaming/public/local', (req, res) => { const onlyMedia = req.query.only_media === '1' || req.query.only_media === 'true'; const channel = onlyMedia ? 'timeline:public:local:media' : 'timeline:public:local'; - streamFrom(channel, req, streamToHttp(req, res), streamHttpEnd(req), true); + streamFrom(channel, req, streamToHttp(req, res), streamHttpEnd(req), true, false, true); }); app.get('/api/v1/streaming/public/remote', (req, res) => { @@ -645,8 +648,11 @@ const startWorker = (workerId) => { case 'public': streamFrom('timeline:public', req, streamToWs(req, ws), streamWsEnd(req, ws), true); break; + case 'public:allow_local_only': + streamFrom('timeline:public', req, streamToWs(req, ws), streamWsEnd(req, ws), true, false, true); + break; case 'public:local': - streamFrom('timeline:public:local', req, streamToWs(req, ws), streamWsEnd(req, ws), true); + streamFrom('timeline:public:local', req, streamToWs(req, ws), streamWsEnd(req, ws), true, false, true); break; case 'public:remote': streamFrom('timeline:public:remote', req, streamToWs(req, ws), streamWsEnd(req, ws), true); @@ -654,8 +660,11 @@ const startWorker = (workerId) => { case 'public:media': streamFrom('timeline:public:media', req, streamToWs(req, ws), streamWsEnd(req, ws), true); break; + case 'public:allow_local_only:media': + streamFrom('timeline:public:media', req, streamToWs(req, ws), streamWsEnd(req, ws), true, false, true); + break; case 'public:local:media': - streamFrom('timeline:public:local:media', req, streamToWs(req, ws), streamWsEnd(req, ws), true); + streamFrom('timeline:public:local:media', req, streamToWs(req, ws), streamWsEnd(req, ws), true, false, true); break; case 'public:remote:media': streamFrom('timeline:public:remote:media', req, streamToWs(req, ws), streamWsEnd(req, ws), true); |