module.exports = {
	schema: true,
	attributes: {
		Site: 'object',
		host: 'string',
		uri: 'string',
		data: 'string',
		severity: 'string',
		closed: {
			type: 'boolean',
			defaultsTo: false
		},
		child_count: {
			type: 'integer',
			defaultsTo: 0
		},
		hash: 'string'
	},
	createOrAppendChild: function(req, res, next) {
		var crypto = require('crypto');
		if (req.body.data) {
			var hash = crypto.createHash('md5').update(req.body.data).digest('hex');
			Log.findOne({hash: hash, site: req.body.site}, function(err, log) {
				if (err) return console.log(err);
				if (!log) {
					// Create Log Record
					req.body.hash = hash;
					Site.findOne(req.body.site_id, function(err, site) {
						if (err) return console.log(err);
						if (site) {
							req.body.Site = site;
						}
						Log.create(req.body).done(function(err, model) {
							if (err) return console.log(err);
							res.status(201);
							Log.publishCreate(model.toJSON());
							next(null, model.toJSON());
						});
					})
				} else {
					if (!log.child_count) {
						log.child_count = 1;
					} else {
						log.child_count++;
					}
					log.closed = false;
					log.save(function(err) {
						if (err) return console.log(err);
						res.status(200);
						Log.publishUpdate(log.id, log.toJSON());
						next(null, log.toJSON());
					})
				}
			})
		}
	}
};

@@ -1333,16 +1333,45 @@
 %7D%0A%09%09%09%7D)%0A
+%09%09%7D else %7B%0A%09%09%09res.send(400);%0A
 %09%09%7D%0A%09%7D%0A%7D

send 400 response if bad data