<commit_before>var S = require('string'),

	NodeBB = module.require('./nodebb'),
	Config = require('./config'),
	Backend = require('./backend'),

	User = NodeBB.User,
	SocketIndex = NodeBB.SocketIndex;

//todo clean this up and improve
var Sockets = {
	get: function(socket, data, callback) {
		var start, end;
		if (data && (data.start && data.end)) {
			start = parseInt(data.start, 10);
			end = parseInt(data.end, 10);
		} else {
			start = -(parseInt(Config.get('shoutlimit'), 10) - 1);
			end = -1;
		}
		if (socket.uid) {
			Backend.getShouts(start, end, function(err, messages) {
				if (err)
					return callback(null, []);

				callback(null, messages);
			});
		} else {
			callback(null, []);
		}
	},
	send: function(socket, data, callback) {
		if (socket.uid === 0) {
			return;
		}

		var msg = S(data.message).stripTags().trim().s;
		User.getMultipleUserFields([socket.uid], ['username', 'picture', 'userslug', 'status'], function(err, userData) {
			if(err) {
				return;
			}

			userData = userData[0];
			userData.uid = socket.uid;
			Backend.parse(msg, userData, true, function(err, data) {
				Backend.addShout(socket.uid, msg, function(err, message) {
					message.data = data;
					SocketIndex.server.sockets.emit('event:shoutbox.receive', message);
				});
			});
		});
	},
	remove: function(socket, data, callback) {
		if (data.sid) {
			Backend.removeShout(data.sid.toString(), socket.uid, function(err, result) {
				if (result === true) {
					SocketIndex.server.sockets.emit('event:shoutbox.delete', {
						id: data.sid
					});
				}
				callback(err, result);
			});
		}
	},
	edit: function(socket, data, callback) {
		if (data.sid) {
			var msg = S(data.edited).stripTags().s;
			Backend.editShout(data.sid.toString(), msg, socket.uid, function(err, result) {
				if (err === null) {
					SocketIndex.server.sockets.emit('event:shoutbox.edit', {
						id: data.sid,
						content: result.content
					});
					result = true;
				}<commit_msg>You guys with your fucking spaces<commit_after>var S = require('string'),

	NodeBB = module.require('./nodebb'),
	Config = require('./config'),
	Backend = require('./backend'),

	User = NodeBB.User,
	SocketIndex = NodeBB.SocketIndex;

//todo clean this up and improve
var Sockets = {
	get: function(socket, data, callback) {
		var start, end;
		if (data && (data.start && data.end)) {
			start = parseInt(data.start, 10);
			end = parseInt(data.end, 10);
		} else {
			start = -(parseInt(Config.get('shoutlimit'), 10) - 1);
			end = -1;
		}
		if (socket.uid) {
			Backend.getShouts(start, end, function(err, messages) {
				if (err)
					return callback(null, []);

				callback(null, messages);
			});
		} else {
			callback(null, []);
		}
	},
	send: function(socket, data, callback) {
		if (socket.uid === 0) {
			return;
		}

		var msg = S(data.message).stripTags().trim().s;
		if (msg.length) {
			User.getMultipleUserFields([socket.uid], ['username', 'picture', 'userslug', 'status'], function(err, userData) {
				if(err) {
					return;
				}

				userData = userData[0];
				userData.uid = socket.uid;
				Backend.parse(msg, userData, true, function(err, data) {
					Backend.addShout(socket.uid, msg, function(err, message) {
						message.data = data;
						SocketIndex.server.sockets.emit('event:shoutbox.receive', message);
					});
				});
			});
		}
	},
	remove: function(socket, data, callback) {
		if (data.sid) {
			Backend.removeShout(data.sid.toString(), socket.uid, function(err, result) {
				if (result === true) {
					SocketIndex.server.sockets.emit('event:shoutbox.delete', {
						id: data.sid
					});
				}
				callback(err, result);
			});
		}
	},
	edit: function(socket, data, callback) {
		if (data.sid) {
			var msg = S(data.edited).stripTags().s;
			Backend.editShout(data.sid.toString(), msg, socket.uid, function(err, result) {
				if (err === null) {
					SocketIndex.server.sockets.emit('event:shoutbox.edit', {
						id: data.sid,
						content: result.content
					});
					result = true;
				}
{'fraction_non_alphanumeric': 0.17843773396556026, 'fraction_numerical': 0.0049912652857499375, 'mean_word_length': 3.175, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6763654', 'n_tokens_mistral': 1677, 'n_tokens_neox': 1390, 'n_words': 283}