Gitter migration: Setup redirects (rollout pt. 3)
[gitter.git] / server / handlers / renderers / embed-renderer.js
blob0887207f5070ffe91f93266e05750f533d23961a
1 'use strict';
3 var renderChat = require('./chat-internal');
4 var roomMembershipService = require('gitter-web-rooms/lib/room-membership-service');
6 function renderSecondaryView(req, res, next, options) {
7 var uriContext = options.uriContext;
8 var troupe = uriContext.troupe;
10 if (!troupe) return next('route');
12 roomMembershipService
13 .countMembersInRoom(req.troupe._id)
14 .then(function(userCount) {
15 const baseOptions = {
16 embedded: true,
17 uriContext: req.uriContext,
18 classNames: ['embedded'],
19 fetchEvents: false,
20 fetchUsers: false,
21 extras: {
22 usersOnline: userCount
26 if (req.user) {
27 return renderChat(req, res, next, {
28 ...baseOptions,
29 template: 'chat-embed-template',
30 script: 'router-embed-chat'
31 });
32 } else {
33 return renderChat(req, res, next, {
34 ...baseOptions,
35 template: 'chat-nli-embed-template',
36 script: 'router-nli-embed-chat'
37 });
40 .catch(next);
43 module.exports = {
44 renderSecondaryView: renderSecondaryView