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!'));
}
let self = this;
const self = this;
async.series(
[
function beginTransaction(callback) {
Message.startTransaction(err => {
callback(err);
return callback(err);
});
},
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)
VALUES (?, ?, ?, ?, ?, ?, ?, ?);`,
[ 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) {
self.messageId = this.lastID;
}
callback(err);
return callback(err);
}
);
},
function storeMeta(callback) {
if(!self.meta) {
callback(null);
} else {
return callback(null);
}
/*
Example of self.meta:
@ -412,16 +412,15 @@ Message.prototype.persist = function(cb) {
}, err => {
callback(err);
});
}
},
function storeHashTags(callback) {
// :TODO: hash tag support
callback(null);
return callback(null);
}
],
err => {
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(
[
function persistMessageToDisc(callback) {
message.persist(callback);
return message.persist(callback);
},
function recordToMessageNetworks(callback) {
msgNetRecord(message, callback);
return msgNetRecord(message, callback);
}
],
cb