* Use per-network outbound for NetMail just like EchoMail

* Use BSO style FLO file for NetMail
* Some code cleanup
This commit is contained in:
Bryan Ashby 2017-12-31 18:45:39 -07:00
parent fc40641eeb
commit 11a19d899e
2 changed files with 62 additions and 50 deletions

View File

@ -2,7 +2,6 @@
'use strict'; 'use strict';
// ENiGMA½ // ENiGMA½
const miscUtil = require('./misc_util.js');
// deps // deps
const fs = require('graceful-fs'); const fs = require('graceful-fs');
@ -147,14 +146,12 @@ function getDefaultConfig() {
webMax : 255, webMax : 255,
requireActivation : false, // require SysOp activation? false = auto-activate requireActivation : false, // require SysOp activation? false = auto-activate
invalidUsernames : [],
groups : [ 'users', 'sysops' ], // built in groups groups : [ 'users', 'sysops' ], // built in groups
defaultGroups : [ 'users' ], // default groups new users belong to defaultGroups : [ 'users' ], // default groups new users belong to
newUserNames : [ 'new', 'apply' ], // Names reserved for applying newUserNames : [ 'new', 'apply' ], // Names reserved for applying
// :TODO: Mystic uses TRASHCAN.DAT for this -- is there a reason to support something like that?
badUserNames : [ badUserNames : [
'sysop', 'admin', 'administrator', 'root', 'all', 'sysop', 'admin', 'administrator', 'root', 'all',
'areamgr', 'filemgr', 'filefix', 'areafix', 'allfix' 'areamgr', 'filemgr', 'filefix', 'areafix', 'allfix'
@ -620,7 +617,7 @@ function getDefaultConfig() {
inbound : paths.join(__dirname, './../mail/ftn_in/'), inbound : paths.join(__dirname, './../mail/ftn_in/'),
secInbound : paths.join(__dirname, './../mail/ftn_secin/'), secInbound : paths.join(__dirname, './../mail/ftn_secin/'),
reject : paths.join(__dirname, './../mail/reject/'), // bad pkt, bundles, TIC attachments that fail any check, etc. reject : paths.join(__dirname, './../mail/reject/'), // bad pkt, bundles, TIC attachments that fail any check, etc.
outboundNetMail : paths.join(__dirname, './../mail/ftn_netmail_out/'), //outboundNetMail : paths.join(__dirname, './../mail/ftn_netmail_out/'),
// set 'retain' to a valid path to keep good pkt files // set 'retain' to a valid path to keep good pkt files
}, },

View File

@ -893,6 +893,8 @@ function FTNMessageScanTossModule() {
exportOpts.fileCase = config.fileCase || 'lower'; exportOpts.fileCase = config.fileCase || 'lower';
exportOpts.network = Config.messageNetworks.ftn.networks[networkName]; exportOpts.network = Config.messageNetworks.ftn.networks[networkName];
exportOpts.networkName = networkName; exportOpts.networkName = networkName;
exportOpts.outgoingDir = self.getOutgoingEchoMailPacketDir(exportOpts.networkName, exportOpts.destAddress);
exportOpts.exportType = self.getExportType(config);
if(!exportOpts.network) { if(!exportOpts.network) {
return callback(Errors.DoesNotExist(`No configuration found for network ${networkName}`)); return callback(Errors.DoesNotExist(`No configuration found for network ${networkName}`));
@ -903,19 +905,32 @@ function FTNMessageScanTossModule() {
}, },
function createOutgoingDir(callback) { function createOutgoingDir(callback) {
// ensure outgoing NetMail directory exists // ensure outgoing NetMail directory exists
return fse.mkdirs(Config.scannerTossers.ftn_bso.paths.outboundNetMail, callback); return fse.mkdirs(exportOpts.outgoingDir, callback);
//return fse.mkdirs(Config.scannerTossers.ftn_bso.paths.outboundNetMail, callback);
}, },
function exportPacket(callback) { function exportPacket(callback) {
return self.exportNetMailMessagePacket(message, exportOpts, callback); return self.exportNetMailMessagePacket(message, exportOpts, callback);
}, },
function moveToOutgoing(callback) { function moveToOutgoing(callback) {
const newExt = exportOpts.fileCase === 'lower' ? '.pkt' : '.PKT'; const newExt = exportOpts.fileCase === 'lower' ? '.pkt' : '.PKT';
const newPath = paths.join( exportOpts.exportedToPath = paths.join(
Config.scannerTossers.ftn_bso.paths.outboundNetMail, exportOpts.outgoingDir,
//Config.scannerTossers.ftn_bso.paths.outboundNetMail,
`${paths.basename(exportOpts.pktFileName, paths.extname(exportOpts.pktFileName))}${newExt}` `${paths.basename(exportOpts.pktFileName, paths.extname(exportOpts.pktFileName))}${newExt}`
); );
return fse.move(exportOpts.pktFileName, newPath, callback); return fse.move(exportOpts.pktFileName, exportOpts.exportedToPath, callback);
},
function prepareFloFile(callback) {
const flowFilePath = self.getOutgoingFlowFileName(
exportOpts.outgoingDir,
exportOpts.destAddress,
'ref',
exportOpts.exportType,
exportOpts.fileCase
);
return self.flowFileAppendRefs(flowFilePath, [ exportOpts.exportedToPath ], '^', callback);
}, },
function storeStateFlags0Meta(callback) { function storeStateFlags0Meta(callback) {
return message.persistMetaValue('System', 'state_flags0', Message.StateFlags0.Exported.toString(), callback); return message.persistMetaValue('System', 'state_flags0', Message.StateFlags0.Exported.toString(), callback);