From c4518c7b9498d4f2da9b99207ae746395ad31873 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Sun, 25 Sep 2022 14:00:52 -0600 Subject: [PATCH] Tidy/DRY --- core/servers/content/nntp.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/core/servers/content/nntp.js b/core/servers/content/nntp.js index f6fc82f8..2580e573 100644 --- a/core/servers/content/nntp.js +++ b/core/servers/content/nntp.js @@ -273,6 +273,7 @@ class NNTPServer extends NNTPServerBase { message.nntpHeaders = { From: this.getJAMStyleFrom(message, fromName), 'X-Comment-To': toName, + To: toName, // JAM-ish Newsgroups: session.group.name, Subject: message.subject, Date: this.getMessageDate(message), @@ -384,7 +385,7 @@ class NNTPServer extends NNTPServerBase { messageUuid = msg && msg.messageUuid; } else { // request - [, messageUuid] = this.getMessageIdentifierParts(messageId); + [, messageUuid] = NNTPServer.getMessageIdentifierParts(messageId); } if (!_.isString(messageUuid)) { @@ -920,7 +921,7 @@ class NNTPServer extends NNTPServerBase { return this.makeMessageIdentifier(message.messageId, message.messageUuid); } - getMessageIdentifierParts(messageId) { + static getMessageIdentifierParts(messageId) { const m = messageId.match( /<([0-9]+)\.([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})@enigma-bbs>/ ); @@ -999,9 +1000,11 @@ class NNTPServer extends NNTPServerBase { (parsed, callback) => { // gather some initially important bits const subject = parsed.header.get('subject'); - const to = parsed.header.get('to'); // non-standard, may be missing + const to = parsed.header.get('to') || parsed.header.get('x-jam-to'); // non-standard, may be missing const from = tidyFrom( - parsed.header.get('from') || parsed.header.get('sender') + parsed.header.get('from') || + parsed.header.get('sender') || + parsed.header.get('x-jam-from') ); const date = parsed.header.get('date'); // if not present we'll use 'now' const newsgroups = parsed.header @@ -1085,18 +1088,15 @@ class NNTPServer extends NNTPServerBase { msgData.parsed.header.get('in-reply-to') || msgData.parsed.header.get('references') || '' - ) - .split(' ')[0] - .replace(/[\<\>]/g, ''); + ).split(' ')[0]; if (parentMessageId) { - let m = /[0-9]+\.([0-9a-f\-]{36})@enigma-bbs/.exec( - parentMessageId - ); - if (m && m[1]) { + let [_, messageUuid] = + NNTPServer.getMessageIdentifierParts(parentMessageId); + if (messageUuid) { const filter = { resultType: 'messageList', - uuids: m[1], + uuids: messageUuid, limit: 1, }; @@ -1131,6 +1131,7 @@ class NNTPServer extends NNTPServerBase { Message.AddressFlavor.NNTP; // :TODO: investigate JAMNTTP clients/etc. + // :TODO: slurp in various X-XXXX kludges/etc. and bring them in persistMessage(message, err => { if (!err) {