diff --git a/core/database.js b/core/database.js index a77836dd..32719179 100644 --- a/core/database.js +++ b/core/database.js @@ -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),' + diff --git a/core/ftn_mail_packet.js b/core/ftn_mail_packet.js index 0777650d..4eb7b83f 100644 --- a/core/ftn_mail_packet.js +++ b/core/ftn_mail_packet.js @@ -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 : [], diff --git a/core/message.js b/core/message.js index 7c344845..ce44071f 100644 --- a/core/message.js +++ b/core/message.js @@ -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) {