* Change meta categories to a integer
This commit is contained in:
parent
801771d7b1
commit
306e84b323
|
@ -132,7 +132,7 @@ function createMessageBaseTables() {
|
|||
dbs.message.run(
|
||||
'CREATE TABLE IF NOT EXISTS message_meta (' +
|
||||
' message_id INTEGER NOT NULL,' +
|
||||
' meta_category VARCHAR NOT NULL,' +
|
||||
' meta_category INTEGER NOT NULL,' +
|
||||
' meta_name VARCHAR NOT NULL,' +
|
||||
' meta_value VARCHAR NOT NULL,' +
|
||||
' UNIQUE(message_id, meta_category, meta_name, meta_value),' +
|
||||
|
|
|
@ -121,21 +121,21 @@ function FTNMailPacket(options) {
|
|||
|
||||
self.getMessageMeta = function(msgBody) {
|
||||
var meta = {
|
||||
ftn_kludge : msgBody.kludgeLines,
|
||||
ftn_control : {},
|
||||
FtnKludge : msgBody.kludgeLines,
|
||||
FtnProperty : {},
|
||||
};
|
||||
|
||||
if(msgBody.tearLine) {
|
||||
meta.ftn_control.ftn_tear_line = [ msgBody.tearLine ];
|
||||
meta.FtnProperty.ftn_tear_line = [ msgBody.tearLine ];
|
||||
}
|
||||
if(msgBody.seenBy.length > 0) {
|
||||
meta.ftn_control.ftn_seen_by = msgBody.seenBy;
|
||||
meta.FtnProperty.ftn_seen_by = msgBody.seenBy;
|
||||
}
|
||||
if(msgBody.area) {
|
||||
meta.ftn_control.ftn_area = [ msgBody.area ];
|
||||
meta.FtnProperty.ftn_area = [ msgBody.area ];
|
||||
}
|
||||
if(msgBody.originLine) {
|
||||
meta.ftn_control.ftn_origin = [ msgBody.originLine ];
|
||||
meta.FtnProperty.ftn_origin = [ msgBody.originLine ];
|
||||
}
|
||||
|
||||
return meta;
|
||||
|
@ -169,7 +169,8 @@ function FTNMailPacket(options) {
|
|||
|
||||
//var msgLines = msgBodyBuffer.toString().split(/\r\n|[\n\v\f\r\x85\u2028\u2029]/g);
|
||||
|
||||
var msgLines = iconv.decode(msgBodyBuffer, 'CP437').replace(/\xec/g, '').split(/\r\n|[\r\n]/g);
|
||||
//var msgLines = iconv.decode(msgBodyBuffer, 'CP437').replace(/\xec/g, '').split(/\r\n|[\r\n]/g);
|
||||
var msgLines = iconv.decode(msgBodyBuffer, 'CP437').replace(/[\xec\n]/g, '').split(/\r/g);
|
||||
|
||||
var msgBody = {
|
||||
message : [],
|
||||
|
|
|
@ -75,10 +75,9 @@ Message.WellKnownAreaIds = {
|
|||
};
|
||||
|
||||
Message.MetaCategories = {
|
||||
System : 'system',
|
||||
FtnProperty : 'ftn_prop', //
|
||||
FtnKludge : 'ftn_kludge', // PATH, MSGID, ...
|
||||
FtnControl : 'ftn_control' // ftn_area, ftn_origin, ...
|
||||
System : 1, // ENiGMA1/2 stuff
|
||||
FtnProperty : 2, // Various FTN network properties, ftn_cost, ftn_origin, ...
|
||||
FtnKludge : 3, // FTN kludges -- PATH, MSGID, ...
|
||||
};
|
||||
|
||||
Message.SystemMetaNames = {
|
||||
|
@ -97,18 +96,14 @@ Message.FtnPropertyNames = {
|
|||
FtnOrigPoint : 'ftn_orig_point',
|
||||
FtnDestPoint : 'ftn_dest_point',
|
||||
FtnAttribute : 'ftn_attribute',
|
||||
};
|
||||
|
||||
// Note: kludges are stored with their names as-is
|
||||
|
||||
Message.FtnControlNames = {
|
||||
FtnTearLine : 'ftn_tear_line', // http://ftsc.org/docs/fts-0004.001
|
||||
FtnOrigin : 'ftn_origin', // http://ftsc.org/docs/fts-0004.001
|
||||
FtnArea : 'ftn_area', // http://ftsc.org/docs/fts-0004.001
|
||||
FtnSeenBy : 'ftn_seen_by', // http://ftsc.org/docs/fts-0004.001
|
||||
};
|
||||
|
||||
// meta: { 'categoryName' : { name : value, name : value, ... } }
|
||||
// Note: kludges are stored with their names as-is
|
||||
|
||||
Message.prototype.setLocalToUserId = function(userId) {
|
||||
this.meta.system.local_to_user_id = userId;
|
||||
|
@ -158,7 +153,7 @@ Message.prototype.persist = function(cb) {
|
|||
|
||||
for(var metaCategroy in self.meta) {
|
||||
async.each(Object.keys(self.meta[metaCategroy]), function meta(metaName, next) {
|
||||
metaStmt.run(self.messageId, metaCategroy, metaName, self.meta[metaCategroy][metaName], function inserted(err) {
|
||||
metaStmt.run(self.messageId, Message.MetaCategories[metaCategroy], metaName, self.meta[metaCategroy][metaName], function inserted(err) {
|
||||
next(err);
|
||||
});
|
||||
}, function complete(err) {
|
||||
|
|
Loading…
Reference in New Issue