Add streaming API channels for local-only statuses
This commit is contained in:
parent
347a153b3d
commit
c8252759df
3 changed files with 27 additions and 3 deletions
|
@ -212,11 +212,21 @@ app.get('/api/v1/streaming/public', (req, res) => {
|
|||
streamFrom(redisClient, 'timeline:public', req, streamToHttp(req, res, redisClient), true)
|
||||
})
|
||||
|
||||
app.get('/api/v1/streaming/public/local', (req, res) => {
|
||||
const redisClient = getRedisClient()
|
||||
streamFrom(redisClient, 'timeline:public:local', req, streamToHttp(req, res, redisClient), true)
|
||||
})
|
||||
|
||||
app.get('/api/v1/streaming/hashtag', (req, res) => {
|
||||
const redisClient = getRedisClient()
|
||||
streamFrom(redisClient, `timeline:hashtag:${req.params.tag}`, req, streamToHttp(req, res, redisClient), true)
|
||||
})
|
||||
|
||||
app.get('/api/v1/streaming/hashtag/local', (req, res) => {
|
||||
const redisClient = getRedisClient()
|
||||
streamFrom(redisClient, `timeline:hashtag:${req.params.tag}:local`, req, streamToHttp(req, res, redisClient), true)
|
||||
})
|
||||
|
||||
wss.on('connection', ws => {
|
||||
const location = url.parse(ws.upgradeReq.url, true)
|
||||
const token = location.query.access_token
|
||||
|
@ -238,9 +248,15 @@ wss.on('connection', ws => {
|
|||
case 'public':
|
||||
streamFrom(redisClient, 'timeline:public', req, streamToWs(req, ws, redisClient), true)
|
||||
break;
|
||||
case 'public:local':
|
||||
streamFrom(redisClient, 'timeline:public:local', req, streamToWs(req, ws, redisClient), true)
|
||||
break;
|
||||
case 'hashtag':
|
||||
streamFrom(redisClient, `timeline:hashtag:${location.query.tag}`, req, streamToWs(req, ws, redisClient), true)
|
||||
break;
|
||||
case 'hashtag:local':
|
||||
streamFrom(redisClient, `timeline:hashtag:${location.query.tag}:local`, req, streamToWs(req, ws, redisClient), true)
|
||||
break;
|
||||
default:
|
||||
ws.close()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue