minor cleanup

This commit is contained in:
Bryan Ashby 2016-09-14 21:08:59 -06:00
parent e90cf673e3
commit 34474bc610
2 changed files with 33 additions and 34 deletions

View File

@ -351,13 +351,13 @@ Message.prototype.persist = function(cb) {
return cb(new Error('Cannot persist invalid message!')); return cb(new Error('Cannot persist invalid message!'));
} }
let self = this; const self = this;
async.series( async.series(
[ [
function beginTransaction(callback) { function beginTransaction(callback) {
Message.startTransaction(err => { Message.startTransaction(err => {
callback(err); return callback(err);
}); });
}, },
function storeMessage(callback) { function storeMessage(callback) {
@ -375,19 +375,19 @@ Message.prototype.persist = function(cb) {
`INSERT INTO message (area_tag, message_uuid, reply_to_message_id, to_user_name, from_user_name, subject, message, modified_timestamp) `INSERT INTO message (area_tag, message_uuid, reply_to_message_id, to_user_name, from_user_name, subject, message, modified_timestamp)
VALUES (?, ?, ?, ?, ?, ?, ?, ?);`, VALUES (?, ?, ?, ?, ?, ?, ?, ?);`,
[ self.areaTag, self.uuid, self.replyToMsgId, self.toUserName, self.fromUserName, self.subject, self.message, self.getMessageTimestampString(msgTimestamp) ], [ self.areaTag, self.uuid, self.replyToMsgId, self.toUserName, self.fromUserName, self.subject, self.message, self.getMessageTimestampString(msgTimestamp) ],
function inserted(err) { // use for this scope function inserted(err) { // use non-arrow function for 'this' scope
if(!err) { if(!err) {
self.messageId = this.lastID; self.messageId = this.lastID;
} }
callback(err); return callback(err);
} }
); );
}, },
function storeMeta(callback) { function storeMeta(callback) {
if(!self.meta) { if(!self.meta) {
callback(null); return callback(null);
} else { }
/* /*
Example of self.meta: Example of self.meta:
@ -412,16 +412,15 @@ Message.prototype.persist = function(cb) {
}, err => { }, err => {
callback(err); callback(err);
}); });
}
}, },
function storeHashTags(callback) { function storeHashTags(callback) {
// :TODO: hash tag support // :TODO: hash tag support
callback(null); return callback(null);
} }
], ],
err => { err => {
Message.endTransaction(err, transErr => { Message.endTransaction(err, transErr => {
cb(err ? err : transErr, self.messageId); return cb(err ? err : transErr, self.messageId);
}); });
} }
); );

View File

@ -560,10 +560,10 @@ function persistMessage(message, cb) {
async.series( async.series(
[ [
function persistMessageToDisc(callback) { function persistMessageToDisc(callback) {
message.persist(callback); return message.persist(callback);
}, },
function recordToMessageNetworks(callback) { function recordToMessageNetworks(callback) {
msgNetRecord(message, callback); return msgNetRecord(message, callback);
} }
], ],
cb cb