gem 'json-ld-preloaded', '~> 3.1'
gem 'rdf-normalize', '~> 0.4'
+gem 'redcarpet', '~> 3.5'
+
group :development, :test do
- gem 'fabrication', '~> 2.22'
+ gem 'fabrication', '~> 2.23'
gem 'fuubar', '~> 2.5'
gem 'i18n-tasks', '~> 0.9', require: false
gem 'pry-byebug', '~> 3.9'
const channelNameFromPath = req => {
const { path, query } = req;
const onlyMedia = isTruthy(query.only_media);
+ const allowLocalOnly = isTruthy(query.allow_local_only);
- switch(path) {
+ switch (path) {
case '/api/v1/streaming/user':
return 'user';
case '/api/v1/streaming/user/notification':
* @param {function(string, string): void} output
* @param {function(string[], function(string): void): void} attachCloseHandler
* @param {boolean=} needsFiltering
+ * @param {boolean=} allowLocalOnly
* @return {function(string): void}
*/
- const streamFrom = (ids, req, output, attachCloseHandler, needsFiltering = false) => {
+ const streamFrom = (ids, req, output, attachCloseHandler, needsFiltering = false, allowLocalOnly = false) => {
- const accountId = req.accountId || req.remoteAddress;
+ const accountId = req.accountId || req.remoteAddress;
log.verbose(req.requestId, `Starting stream from ${ids.join(', ')} for ${accountId}`);
app.get('/api/v1/streaming/*', (req, res) => {
channelNameToIds(req, channelNameFromPath(req), req.query).then(({ channelIds, options }) => {
const onSend = streamToHttp(req, res);
- const onEnd = streamHttpEnd(req, subscriptionHeartbeat(channelIds));
+ const onEnd = streamHttpEnd(req, subscriptionHeartbeat(channelIds));
- streamFrom(channelIds, req, onSend, onEnd, options.needsFiltering);
+ streamFrom(channelIds, req, onSend, onEnd, options.needsFiltering, options.allowLocalOnly);
}).catch(err => {
log.verbose(req.requestId, 'Subscription error:', err.toString());
httpNotFound(res);
return;
}
- const onSend = streamToWs(request, socket, streamNameFromChannelName(channelName, params));
+ const onSend = streamToWs(request, socket, streamNameFromChannelName(channelName, params));
const stopHeartbeat = subscriptionHeartbeat(channelIds);
-
- const listener = streamFrom(channelIds, request, onSend, undefined, options.needsFiltering, options.allowLocalOnly);
- const listener = streamFrom(channelIds, request, onSend, undefined, options.needsFiltering);
++ const listener = streamFrom(channelIds, request, onSend, undefined, options.needsFiltering, options.allowLocalOnly);
subscriptions[channelIds.join(';')] = {
listener,