Add streaming API channels for local-only statuses
parent
347a153b3d
commit
c8252759df
|
@ -66,7 +66,7 @@ const Lightbox = React.createClass({
|
||||||
return (
|
return (
|
||||||
<Motion defaultStyle={{ backgroundOpacity: 0, opacity: 0, y: -400 }} style={{ backgroundOpacity: spring(isVisible ? 50 : 0), opacity: isVisible ? spring(200) : 0, y: spring(isVisible ? 0 : -400, { stiffness: 150, damping: 12 }) }}>
|
<Motion defaultStyle={{ backgroundOpacity: 0, opacity: 0, y: -400 }} style={{ backgroundOpacity: spring(isVisible ? 50 : 0), opacity: isVisible ? spring(200) : 0, y: spring(isVisible ? 0 : -400, { stiffness: 150, damping: 12 }) }}>
|
||||||
{({ backgroundOpacity, opacity, y }) =>
|
{({ backgroundOpacity, opacity, y }) =>
|
||||||
<div className='lightbox' style={{...overlayStyle, background: `rgba(0, 0, 0, ${backgroundOpacity / 100})`, display: Math.floor(backgroundOpacity) === 0 ? 'none' : 'flex'}} onClick={onOverlayClicked}>
|
<div className='lightbox' style={{...overlayStyle, background: `rgba(0, 0, 0, ${backgroundOpacity / 100})`, display: Math.floor(backgroundOpacity) === 0 ? 'none' : 'flex', pointerEvents: !isVisible ? 'none' : 'auto'}} onClick={onOverlayClicked}>
|
||||||
<div style={{...dialogStyle, transform: `translateY(${y}px)`, opacity: opacity / 100 }} onClick={this.stopPropagation}>
|
<div style={{...dialogStyle, transform: `translateY(${y}px)`, opacity: opacity / 100 }} onClick={this.stopPropagation}>
|
||||||
<IconButton title={intl.formatMessage({ id: 'lightbox.close', defaultMessage: 'Close' })} icon='times' onClick={onCloseClicked} size={16} style={closeStyle} />
|
<IconButton title={intl.formatMessage({ id: 'lightbox.close', defaultMessage: 'Close' })} icon='times' onClick={onCloseClicked} size={16} style={closeStyle} />
|
||||||
{children}
|
{children}
|
||||||
|
|
|
@ -34,13 +34,21 @@ class FanOutOnWriteService < BaseService
|
||||||
|
|
||||||
def deliver_to_hashtags(status)
|
def deliver_to_hashtags(status)
|
||||||
Rails.logger.debug "Delivering status #{status.id} to hashtags"
|
Rails.logger.debug "Delivering status #{status.id} to hashtags"
|
||||||
|
|
||||||
|
payload = FeedManager.instance.inline_render(nil, 'api/v1/statuses/show', status)
|
||||||
|
|
||||||
status.tags.find_each do |tag|
|
status.tags.find_each do |tag|
|
||||||
FeedManager.instance.broadcast("hashtag:#{tag.name}", event: 'update', payload: FeedManager.instance.inline_render(nil, 'api/v1/statuses/show', status))
|
FeedManager.instance.broadcast("hashtag:#{tag.name}", event: 'update', payload: payload)
|
||||||
|
FeedManager.instance.broadcast("hashtag:#{tag.name}:local", event: 'update', payload: payload) if status.account.local?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def deliver_to_public(status)
|
def deliver_to_public(status)
|
||||||
Rails.logger.debug "Delivering status #{status.id} to public timeline"
|
Rails.logger.debug "Delivering status #{status.id} to public timeline"
|
||||||
FeedManager.instance.broadcast(:public, event: 'update', payload: FeedManager.instance.inline_render(nil, 'api/v1/statuses/show', status))
|
|
||||||
|
payload = FeedManager.instance.inline_render(nil, 'api/v1/statuses/show', status)
|
||||||
|
|
||||||
|
FeedManager.instance.broadcast(:public, event: 'update', payload: payload)
|
||||||
|
FeedManager.instance.broadcast('public:local', event: 'update', payload: payload) if status.account.local?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -212,11 +212,21 @@ app.get('/api/v1/streaming/public', (req, res) => {
|
||||||
streamFrom(redisClient, 'timeline:public', req, streamToHttp(req, res, redisClient), true)
|
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) => {
|
app.get('/api/v1/streaming/hashtag', (req, res) => {
|
||||||
const redisClient = getRedisClient()
|
const redisClient = getRedisClient()
|
||||||
streamFrom(redisClient, `timeline:hashtag:${req.params.tag}`, req, streamToHttp(req, res, redisClient), true)
|
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 => {
|
wss.on('connection', ws => {
|
||||||
const location = url.parse(ws.upgradeReq.url, true)
|
const location = url.parse(ws.upgradeReq.url, true)
|
||||||
const token = location.query.access_token
|
const token = location.query.access_token
|
||||||
|
@ -238,9 +248,15 @@ wss.on('connection', ws => {
|
||||||
case 'public':
|
case 'public':
|
||||||
streamFrom(redisClient, 'timeline:public', req, streamToWs(req, ws, redisClient), true)
|
streamFrom(redisClient, 'timeline:public', req, streamToWs(req, ws, redisClient), true)
|
||||||
break;
|
break;
|
||||||
|
case 'public:local':
|
||||||
|
streamFrom(redisClient, 'timeline:public:local', req, streamToWs(req, ws, redisClient), true)
|
||||||
|
break;
|
||||||
case 'hashtag':
|
case 'hashtag':
|
||||||
streamFrom(redisClient, `timeline:hashtag:${location.query.tag}`, req, streamToWs(req, ws, redisClient), true)
|
streamFrom(redisClient, `timeline:hashtag:${location.query.tag}`, req, streamToWs(req, ws, redisClient), true)
|
||||||
break;
|
break;
|
||||||
|
case 'hashtag:local':
|
||||||
|
streamFrom(redisClient, `timeline:hashtag:${location.query.tag}:local`, req, streamToWs(req, ws, redisClient), true)
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ws.close()
|
ws.close()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue