Merge branch 'master' of ssh://numinibsd/git/base/enigma-bbs into 216-waiting-for-caller
This commit is contained in:
@@ -160,7 +160,7 @@ ClientTerminal.prototype.write = function(s, convertLineFeeds, cb) {
|
||||
};
|
||||
|
||||
ClientTerminal.prototype.rawWrite = function(s, cb) {
|
||||
if(this.output) {
|
||||
if(this.output && this.output.writable) {
|
||||
this.output.write(s, err => {
|
||||
if(cb) {
|
||||
return cb(err);
|
||||
|
||||
@@ -678,11 +678,28 @@ function Packet(options) {
|
||||
}
|
||||
|
||||
//
|
||||
// If we have a UTC offset kludge (e.g. TZUTC) then update
|
||||
// modDateTime with it
|
||||
// Attempt to handle FTN time zone kludges of 'TZUTC' and
|
||||
// 'TZUTCINFO'.
|
||||
//
|
||||
if(_.isString(msg.meta.FtnKludge.TZUTC) && msg.meta.FtnKludge.TZUTC.length > 0) {
|
||||
msg.modDateTime = msg.modTimestamp.utcOffset(msg.meta.FtnKludge.TZUTC);
|
||||
// See http://ftsc.org/docs/frl-1004.002
|
||||
//
|
||||
const tzKludge = msg.meta.FtnKludge.TZUTC || msg.meta.FtnKludge.TZUTCINFO;
|
||||
const tzMatch = /([+-]?)([0-9]{2})([0-9]{2})/.exec(tzKludge);
|
||||
if (tzMatch) {
|
||||
//
|
||||
// - Both kludges should provide a offset in hhmm format
|
||||
// - Negative offsets must proceed with '-'
|
||||
// - Positive offsets must not (to spec) proceed with '+', but
|
||||
// we'll allow it.
|
||||
//
|
||||
const [, sign, hours, minutes ] = tzMatch;
|
||||
|
||||
// convert to a [+|-]hh:mm format.
|
||||
// example: 1300 -> +13:00
|
||||
const utcOffset = `${sign||'+'}${hours}:${minutes}`;
|
||||
|
||||
// finally, update our modTimestamp
|
||||
msg.modTimestamp = msg.modTimestamp.utcOffset(utcOffset);
|
||||
}
|
||||
|
||||
// :TODO: Parser should give is this info:
|
||||
|
||||
@@ -134,7 +134,7 @@ module.exports = class Message {
|
||||
modTimestamp = moment(modTimestamp);
|
||||
}
|
||||
|
||||
this.modTimestamp = modTimestamp;
|
||||
this.modTimestamp = modTimestamp || moment();
|
||||
|
||||
this.meta = {};
|
||||
_.defaultsDeep(this.meta, { System : {} }, meta);
|
||||
@@ -695,11 +695,10 @@ module.exports = class Message {
|
||||
},
|
||||
function storeMessage(trans, callback) {
|
||||
// generate a UUID for this message if required (general case)
|
||||
const msgTimestamp = moment();
|
||||
if(!self.messageUuid) {
|
||||
self.messageUuid = Message.createMessageUUID(
|
||||
self.areaTag,
|
||||
msgTimestamp,
|
||||
self.modTimestamp,
|
||||
self.subject,
|
||||
self.message
|
||||
);
|
||||
@@ -710,7 +709,7 @@ module.exports = class Message {
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?);`,
|
||||
[
|
||||
self.areaTag, self.messageUuid, self.replyToMsgId, self.toUserName,
|
||||
self.fromUserName, self.subject, self.message, getISOTimestampString(msgTimestamp)
|
||||
self.fromUserName, self.subject, self.message, getISOTimestampString(self.modTimestamp)
|
||||
],
|
||||
function inserted(err) { // use non-arrow function for 'this' scope
|
||||
if(!err) {
|
||||
|
||||
@@ -30,6 +30,10 @@ function initAndGetUser(userName, cb) {
|
||||
const User = require('../../core/user.js');
|
||||
User.getUserIdAndName(userName, (err, userId) => {
|
||||
if(err) {
|
||||
// try user ID if number was supplied
|
||||
if (_.isNumber(userName)) {
|
||||
return User.getUser(parseInt(userName), callback);
|
||||
}
|
||||
return callback(err);
|
||||
}
|
||||
return User.getUser(userId, callback);
|
||||
@@ -329,12 +333,17 @@ function showUserInfo(user) {
|
||||
return user.properties[p] || 'N/A';
|
||||
};
|
||||
|
||||
const currentTheme = () => {
|
||||
return user.properties[UserProps.ThemeId];
|
||||
};
|
||||
|
||||
const stdInfo = `User information:
|
||||
Username : ${user.username}${user.isRoot() ? ' (root/SysOp)' : ''}
|
||||
Real name : ${propOrNA(UserProps.RealName)}
|
||||
ID : ${user.userId}
|
||||
Status : ${statusDesc()}
|
||||
Groups : ${user.groups.join(', ')}
|
||||
Theme ID : ${currentTheme()}
|
||||
Created : ${created()}
|
||||
Last login : ${lastLogin()}
|
||||
Login count : ${propOrNA(UserProps.LoginCount)}
|
||||
|
||||
@@ -1879,6 +1879,8 @@ function FTNMessageScanTossModule() {
|
||||
localInfo.fileEntry.fileName = paths.basename(finalPath);
|
||||
}
|
||||
|
||||
localInfo.newPath = dst;
|
||||
|
||||
localInfo.fileEntry.persist(isUpdate, err => {
|
||||
return callback(err, localInfo);
|
||||
});
|
||||
@@ -1893,6 +1895,12 @@ function FTNMessageScanTossModule() {
|
||||
const oldStorageDir = getAreaStorageDirectoryByTag(localInfo.oldStorageTag);
|
||||
const oldPath = paths.join(oldStorageDir, localInfo.oldFileName);
|
||||
|
||||
// if we updated a file in place, don't delete it!
|
||||
if (localInfo.newPath === oldPath) {
|
||||
Log.trace({path : oldPath}, 'TIC file replaced in place. Nothing to remove.');
|
||||
return callback(null, localInfo);
|
||||
}
|
||||
|
||||
fs.unlink(oldPath, err => {
|
||||
if(err) {
|
||||
Log.warn( { error : err.message, oldPath : oldPath }, 'Failed removing old physical file during TIC replacement');
|
||||
|
||||
Reference in New Issue
Block a user