mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-06 04:37:12 +02:00
* Lots of work on message loading from message list and extraArgs
This commit is contained in:
parent
e852695354
commit
02e90d7ca3
8 changed files with 311 additions and 54 deletions
|
@ -11,6 +11,7 @@ var assert = require('assert');
|
|||
module.exports = Message;
|
||||
|
||||
function Message(options) {
|
||||
options = options || {};
|
||||
|
||||
this.messageId = options.messageId || 0; // always generated @ persist
|
||||
this.areaName = options.areaName || Message.WellKnownAreaNames.Invalid;
|
||||
|
@ -122,6 +123,58 @@ Message.prototype.setLocalFromUserId = function(userId) {
|
|||
this.meta.system.local_from_user_id = userId;
|
||||
};
|
||||
|
||||
Message.prototype.load = function(options, cb) {
|
||||
assert(_.isString(options.uuid));
|
||||
|
||||
var self = this;
|
||||
|
||||
async.series(
|
||||
[
|
||||
function loadMessage(callback) {
|
||||
msgDb.get(
|
||||
'SELECT message_id, area_name, message_uuid, reply_to_message_id, to_user_name, from_user_name, subject, ' +
|
||||
'message, modified_timestamp, view_count ' +
|
||||
'FROM message ' +
|
||||
'WHERE message_uuid=? ' +
|
||||
'LIMIT 1;',
|
||||
[ options.uuid ],
|
||||
function row(err, msgRow) {
|
||||
self.messageId = msgRow.message_id;
|
||||
self.areaName = msgRow.area_name;
|
||||
self.messageUuid = msgRow.message_uuid;
|
||||
self.replyToMsgId = msgRow.reply_to_message_id;
|
||||
self.toUserName = msgRow.to_user_name;
|
||||
self.fromUserName = msgRow.from_user_name;
|
||||
self.subject = msgRow.subject;
|
||||
self.message = msgRow.message;
|
||||
self.modTimestamp = msgRow.modified_timestamp;
|
||||
self.viewCount = msgRow.view_count;
|
||||
|
||||
callback(err);
|
||||
}
|
||||
);
|
||||
},
|
||||
function loadMessageMeta(callback) {
|
||||
// :TODO:
|
||||
callback(null);
|
||||
},
|
||||
function loadHashTags(callback) {
|
||||
// :TODO:
|
||||
callback(null);
|
||||
},
|
||||
function loadMessageStatus(callback) {
|
||||
if(options.user) {
|
||||
// :TODO: Load from user_message_status
|
||||
}
|
||||
callback(null);
|
||||
}
|
||||
],
|
||||
function complete(err) {
|
||||
cb(err);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
Message.prototype.persist = function(cb) {
|
||||
|
||||
if(!this.isValid()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue