diff --git a/src/ws/channels.js b/src/ws/channels.js index 5fea53a..b4e94e3 100644 --- a/src/ws/channels.js +++ b/src/ws/channels.js @@ -14,7 +14,9 @@ const events = [ 'delete', ]; -const channelEvents = []; +const channelEvents = [ + 'streams:full', +]; channels.forEach((c) => { events.forEach((e) => { diff --git a/src/ws/crud.js b/src/ws/crud.js index 5b71685..671d057 100644 --- a/src/ws/crud.js +++ b/src/ws/crud.js @@ -86,10 +86,12 @@ const matchFns = { const streamFns = { getAll: async () => { return await streams.find().exec() - // return await streams.find().populate('event').populate({ - // path: 'matches', - // populate: [{ path: 'orange' }, { path: 'blue' }], - // }).populate('casters').populate('hosts').exec() + }, + getAllPop: async () => { + return await streams.find().populate('event').populate({ + path: 'matches', + populate: [{ path: 'orange' }, { path: 'blue' }], + }).populate('casters').populate('hosts').exec() }, getById: async (id) => { return await streams.findById(id).populate('event').populate('matches').populate('casters').populate('hosts').exec() diff --git a/src/ws/handler.js b/src/ws/handler.js index 43009bf..b11aa30 100644 --- a/src/ws/handler.js +++ b/src/ws/handler.js @@ -33,6 +33,9 @@ const handleMsg = async (msg, id) => { event: `${channel}:read`, data: await crud[channel].getAll(), } + if (channel === 'streams' && d.subscribe === 'streams:full') { + dm.data = await crud[channel].getAllPop() + } connections[id].connection.send(JSON.stringify(dm)) } else if (d.hasOwnProperty('event') && channelEvents.indexOf(d.event) !== -1) { const ev = d.event.split(':')