Return 404 if room is not found or errs out
//
// Transcript Controller
//

'use strict';

var _ = require('lodash');

module.exports = function() {
    var app = this.app,
        core = this.core,
        middlewares = this.middlewares,
        models = this.models,
        Room = models.room,
        User = models.user;

    //
    // Routes
    //
    app.get('/transcript', middlewares.requireLogin, function(req, res) {
        var roomId = req.param('room');
        core.rooms.get(roomId, function(err, room) {
            if (err || !room) {
                err && console.error(err)
                return res.sendStatus(404);
            }
            res.render('transcript.html', {
                room: {
                    id: roomId,
                    name: room.name
                }
            });
        });
    });
}

//
// Transcript Controller
//

'use strict';

var _ = require('lodash');

module.exports = function() {
    var app = this.app,
        core = this.core,
        middlewares = this.middlewares,
        models = this.models,
        Room = models.room,
        User = models.user;

    //
    // Routes
    //
    app.get('/transcript', middlewares.requireLogin, function(req, res) {
        var roomId = req.param('room');

        core.rooms.get(roomId, function(err, room) {
            if (err) {
                console.error(err);
                return req.io.respond(err, 400);
            }

            res.render('transcript.html', {
                room: {
                    id: roomId,
                    name: room.name
                }
            });
        });
    });
}
