Skip to content
Snippets Groups Projects
Commit f837e9c7 authored by Eric Oulashin's avatar Eric Oulashin Committed by Rob Swindell
Browse files

DDMsgReader: As a loadable module, now make use of user# parameter for reading...

DDMsgReader: As a loadable module, now make use of user# parameter for reading personal email (for the sysop when deleting a user account)
parent 3709ae9d
No related branches found
No related tags found
2 merge requests!463MRC mods by Codefenix (2024-10-20),!254DDMsgReader: As a loadable module, now make use of user# parameter for reading personal email (for the sysop when deleting a user account)
...@@ -91,11 +91,17 @@ ...@@ -91,11 +91,17 @@
* 2023-02-01 Eric Oulashin Version 1.63 * 2023-02-01 Eric Oulashin Version 1.63
* Fix for reading colors from the theme file. Also, the theme file now * Fix for reading colors from the theme file. Also, the theme file now
* no longer needs the control character for color codes. * no longer needs the control character for color codes.
* 2023-02-09 Eric Oulashin Version 1.64
* When reading personal email (received or sent), now makes use of the
* loadable module 2nd command-line argument, which specifies the user number.
* When deleting a user, the sysop might be prompted whether to read that
* user's email.
*/ */
   
"use strict"; "use strict";
   
// TODO: In the message list, add the ability to search with / similar to my area chooser // TODO: In the message list, add the ability to search with / similar to my area chooser.
   
/* Command-line arguments (in -arg=val format, or -arg format to enable an /* Command-line arguments (in -arg=val format, or -arg format to enable an
option): option):
...@@ -195,8 +201,8 @@ var ansiterm = require("ansiterm_lib.js", 'expand_ctrl_a'); ...@@ -195,8 +201,8 @@ var ansiterm = require("ansiterm_lib.js", 'expand_ctrl_a');
   
   
// Reader version information // Reader version information
var READER_VERSION = "1.63"; var READER_VERSION = "1.64";
var READER_DATE = "2023-02-01"; var READER_DATE = "2023-02-09";
   
// Keyboard key codes for displaying on the screen // Keyboard key codes for displaying on the screen
var UP_ARROW = ascii(24); var UP_ARROW = ascii(24);
...@@ -1089,10 +1095,18 @@ function DigDistMsgReader(pSubBoardCode, pScriptArgs) ...@@ -1089,10 +1095,18 @@ function DigDistMsgReader(pSubBoardCode, pScriptArgs)
   
this.cfgFilename = "DDMsgReader.cfg"; this.cfgFilename = "DDMsgReader.cfg";
// Check the command-line arguments for a custom configuration file name // Check the command-line arguments for a custom configuration file name
// before reading the configuration file. // before reading the configuration file. Defaults to the current user
// number, but can be set by a loadable module command-line argument. Also,
// only allow changing it if the current user is a sysop.
this.personalMailUserNum = user.number;
var scriptArgsIsValid = (typeof(pScriptArgs) == "object"); var scriptArgsIsValid = (typeof(pScriptArgs) == "object");
if (scriptArgsIsValid && pScriptArgs.hasOwnProperty("configfilename")) if (scriptArgsIsValid)
this.cfgFilename = pScriptArgs["configfilename"]; {
if (pScriptArgs.hasOwnProperty("configfilename"))
this.cfgFilename = pScriptArgs.configfilename;
if (pScriptArgs.hasOwnProperty("usernum") && user.is_sysop)
this.personalMailUserNum = pScriptArgs.usernum;
}
// Read the settings from the config file // Read the settings from the config file
this.cfgFileSuccessfullyRead = false; this.cfgFileSuccessfullyRead = false;
this.ReadConfigFile(); this.ReadConfigFile();
...@@ -1962,7 +1976,6 @@ function DigDistMsgReader_ClearSearchData() ...@@ -1962,7 +1976,6 @@ function DigDistMsgReader_ClearSearchData()
delete this.msgSearchHdrs[subCode].indexed; delete this.msgSearchHdrs[subCode].indexed;
delete this.msgSearchHdrs[subCode]; delete this.msgSearchHdrs[subCode];
} }
delete this.msgSearchHdrs;
this.msgSearchHdrs = {}; this.msgSearchHdrs = {};
} }
} }
...@@ -2200,7 +2213,8 @@ function DigDistMsgReader_PopulateHdrsIfSearch_DispErrorIfNoMsgs(pCloseMsgbaseAn ...@@ -2200,7 +2213,8 @@ function DigDistMsgReader_PopulateHdrsIfSearch_DispErrorIfNoMsgs(pCloseMsgbaseAn
//console.print("\x01n" + replaceAtCodesInStr(formattedText) + "\x01n"); //console.print("\x01n" + replaceAtCodesInStr(formattedText) + "\x01n");
console.putmsg("\x01n" + formattedText + "\x01n"); console.putmsg("\x01n" + formattedText + "\x01n");
} }
this.msgSearchHdrs[this.subBoardCode] = searchMsgbase(this.subBoardCode, this.searchType, this.searchString, this.readingPersonalEmailFromUser); var readingMailUserNum = user.is_sysop ? this.personalMailUserNum : user.number;
this.msgSearchHdrs[this.subBoardCode] = searchMsgbase(this.subBoardCode, this.searchType, this.searchString, this.readingPersonalEmailFromUser, null, null, readingMailUserNum);
} }
} }
else else
...@@ -9886,6 +9900,8 @@ function DigDistMsgReader_ReplyToMsg(pMsgHdr, pMsgText, pPrivate, pMsgIdx) ...@@ -9886,6 +9900,8 @@ function DigDistMsgReader_ReplyToMsg(pMsgHdr, pMsgText, pPrivate, pMsgIdx)
   
// If quoting is allowed in the sub-board, then write QUOTES.TXT in // If quoting is allowed in the sub-board, then write QUOTES.TXT in
// the node directory to allow the user to quote the original message. // the node directory to allow the user to quote the original message.
// TODO: Handle things when reading another user's email (for the sysop) - "mail" as a sub-board code might
// not work
var msgbase = new MsgBase(this.subBoardCode); var msgbase = new MsgBase(this.subBoardCode);
if (msgbase.open()) if (msgbase.open())
{ {
...@@ -16613,13 +16629,15 @@ function canDoHighASCIIAndANSI() ...@@ -16613,13 +16629,15 @@ function canDoHighASCIIAndANSI()
// pListingPersonalEmailFromUser: Optional boolean - Whether or not we're listing // pListingPersonalEmailFromUser: Optional boolean - Whether or not we're listing
// personal email sent by the user. This defaults // personal email sent by the user. This defaults
// to false. // to false.
// pStartIndex: The starting message index (0-based). Optional; defaults to 0. // pStartIndex: Optional: The starting message index (0-based). Defaults to 0.
// pEndIndex: One past the last message index. Optional; defaults to the total number // pEndIndex: Optional: One past the last message index. Defaults to the total number
// of messages. // of messages.
// //
// pUserNum: Optional: The user number (for reading personal email)
//
// Return value: An object with the following arrays: // Return value: An object with the following arrays:
// indexed: A 0-based indexed array of message headers // indexed: A 0-based indexed array of message headers
function searchMsgbase(pSubCode, pSearchType, pSearchString, pListingPersonalEmailFromUser, pStartIndex, pEndIndex) function searchMsgbase(pSubCode, pSearchType, pSearchString, pListingPersonalEmailFromUser, pStartIndex, pEndIndex, pUserNum)
{ {
var msgHeaders = { var msgHeaders = {
indexed: [] indexed: []
...@@ -16662,8 +16680,7 @@ function searchMsgbase(pSubCode, pSearchType, pSearchString, pListingPersonalEma ...@@ -16662,8 +16680,7 @@ function searchMsgbase(pSubCode, pSearchType, pSearchString, pListingPersonalEma
{ {
matchFn = function(pSearchStr, pMsgHdr, pMsgBase, pSubBoardCode) { matchFn = function(pSearchStr, pMsgHdr, pMsgBase, pSubBoardCode) {
var msgText = strip_ctrl(pMsgBase.get_msg_body(false, pMsgHdr.number, false, false, true, true)); var msgText = strip_ctrl(pMsgBase.get_msg_body(false, pMsgHdr.number, false, false, true, true));
return gAllPersonalEmailOptSpecified || msgIsFromUser(pMsgHdr); return gAllPersonalEmailOptSpecified || msgIsFromUser(pMsgHdr, pUserNum);
} }
} }
else else
...@@ -16671,7 +16688,7 @@ function searchMsgbase(pSubCode, pSearchType, pSearchString, pListingPersonalEma ...@@ -16671,7 +16688,7 @@ function searchMsgbase(pSubCode, pSearchType, pSearchString, pListingPersonalEma
// We're reading mail to the user // We're reading mail to the user
matchFn = function(pSearchStr, pMsgHdr, pMsgBase, pSubBoardCode) { matchFn = function(pSearchStr, pMsgHdr, pMsgBase, pSubBoardCode) {
var msgText = strip_ctrl(pMsgBase.get_msg_body(false, pMsgHdr.number, false, false, true, true)); var msgText = strip_ctrl(pMsgBase.get_msg_body(false, pMsgHdr.number, false, false, true, true));
var msgMatchesCriteria = (gAllPersonalEmailOptSpecified || msgIsToUserByNum(pMsgHdr)); var msgMatchesCriteria = (gAllPersonalEmailOptSpecified || msgIsToUserByNum(pMsgHdr, pUserNum));
// If only new/unread personal email is to be displayed, then check // If only new/unread personal email is to be displayed, then check
// that the message has not been read. // that the message has not been read.
if (gCmdLineArgVals.onlynewpersonalemail) if (gCmdLineArgVals.onlynewpersonalemail)
...@@ -16851,10 +16868,12 @@ function searchMsgbase(pSubCode, pSearchType, pSearchString, pListingPersonalEma ...@@ -16851,10 +16868,12 @@ function searchMsgbase(pSubCode, pSearchType, pSearchString, pListingPersonalEma
// //
// Parameters: // Parameters:
// pMsgHdr: A message header object // pMsgHdr: A message header object
// pUserNum: Optional - A user number to match with. If not specified, this will default to
// the current logged-in user number.
// //
// Return value: Boolean - Whether or not the message is to the user and is not // Return value: Boolean - Whether or not the message is to the user and is not
// deleted. // deleted.
function msgIsToUserByNum(pMsgHdr) function msgIsToUserByNum(pMsgHdr, pUserNum)
{ {
if (typeof(pMsgHdr) != "object") if (typeof(pMsgHdr) != "object")
return false; return false;
...@@ -16862,13 +16881,17 @@ function msgIsToUserByNum(pMsgHdr) ...@@ -16862,13 +16881,17 @@ function msgIsToUserByNum(pMsgHdr)
if ((pMsgHdr.attr & MSG_DELETE) == MSG_DELETE) if ((pMsgHdr.attr & MSG_DELETE) == MSG_DELETE)
return false; return false;
   
var userNum = user.number;
if (user.is_sysop && typeof(pUserNum) === "number" && pUserNum > 0 && pUserNum <= system.lastuser)
userNum = pUserNum;
var msgIsToUser = false; var msgIsToUser = false;
// If an alternate user number was specified on the command line, then use that // If an alternate user number was specified on the command line, then use that
// user information. Otherwise, use the current logged-in user. // user information. Otherwise, use the current logged-in user.
if (gCmdLineArgVals.hasOwnProperty("altUserNum")) if (gCmdLineArgVals.hasOwnProperty("altUserNum"))
msgIsToUser = (pMsgHdr.to_ext == gCmdLineArgVals.altUserNum); msgIsToUser = (pMsgHdr.to_ext == gCmdLineArgVals.altUserNum);
else else
msgIsToUser = (pMsgHdr.to_ext == user.number); msgIsToUser = (pMsgHdr.to_ext == userNum);
return msgIsToUser; return msgIsToUser;
} }
   
...@@ -16878,10 +16901,12 @@ function msgIsToUserByNum(pMsgHdr) ...@@ -16878,10 +16901,12 @@ function msgIsToUserByNum(pMsgHdr)
// //
// Parameters: // Parameters:
// pMsgHdr: A message header object // pMsgHdr: A message header object
// pUserNum: Optional - A user number to match with. If not specified, this will default to
// the current logged-in user number.
// //
// Return value: Boolean - Whether or not the message is from the logged-in user // Return value: Boolean - Whether or not the message is from the logged-in user
// and is not deleted. // and is not deleted.
function msgIsFromUser(pMsgHdr) function msgIsFromUser(pMsgHdr, pUserNum)
{ {
if (typeof(pMsgHdr) != "object") if (typeof(pMsgHdr) != "object")
return false; return false;
...@@ -16889,6 +16914,8 @@ function msgIsFromUser(pMsgHdr) ...@@ -16889,6 +16914,8 @@ function msgIsFromUser(pMsgHdr)
if ((pMsgHdr.attr & MSG_DELETE) == MSG_DELETE) if ((pMsgHdr.attr & MSG_DELETE) == MSG_DELETE)
return false; return false;
   
var pUserNumIsValid = (typeof(pUserNum) === "number" && pUserNum > 0 && pUserNum <= system.lastuser);
var isFromUser = false; var isFromUser = false;
   
// If an alternate user number was specified on the command line, then use that // If an alternate user number was specified on the command line, then use that
...@@ -16899,7 +16926,7 @@ function msgIsFromUser(pMsgHdr) ...@@ -16899,7 +16926,7 @@ function msgIsFromUser(pMsgHdr)
if (gCmdLineArgVals.hasOwnProperty("altUserNum")) if (gCmdLineArgVals.hasOwnProperty("altUserNum"))
isFromUser = (pMsgHdr.from_ext == gCmdLineArgVals.altUserNum); isFromUser = (pMsgHdr.from_ext == gCmdLineArgVals.altUserNum);
else else
isFromUser = (pMsgHdr.from_ext == user.number); isFromUser = (pMsgHdr.from_ext == (pUserNumIsValid && user.is_sysop ? pUserNum : user.number));
} }
else else
{ {
...@@ -16907,7 +16934,15 @@ function msgIsFromUser(pMsgHdr) ...@@ -16907,7 +16934,15 @@ function msgIsFromUser(pMsgHdr)
if (gCmdLineArgVals.hasOwnProperty("altUserName") && gCmdLineArgVals.hasOwnProperty("altUserAlias")) if (gCmdLineArgVals.hasOwnProperty("altUserName") && gCmdLineArgVals.hasOwnProperty("altUserAlias"))
isFromUser = ((hdrFromUpper == gCmdLineArgVals.altUserAlias.toUpperCase()) || (hdrFromUpper == gCmdLineArgVals.altUserName.toUpperCase())); isFromUser = ((hdrFromUpper == gCmdLineArgVals.altUserAlias.toUpperCase()) || (hdrFromUpper == gCmdLineArgVals.altUserName.toUpperCase()));
else else
isFromUser = ((hdrFromUpper == user.alias.toUpperCase()) || (hdrFromUpper == user.name.toUpperCase())); {
if (pUserNumIsValid)
{
var theUser = new User(pUserNum);
isFromUser = ((hdrFromUpper == theUser.alias.toUpperCase()) || (hdrFromUpper == theUser.name.toUpperCase()));
}
else
isFromUser = ((hdrFromUpper == user.alias.toUpperCase()) || (hdrFromUpper == user.name.toUpperCase()));
}
} }
   
return isFromUser; return isFromUser;
...@@ -17185,13 +17220,13 @@ function parseLoadableModuleArgs(argv) ...@@ -17185,13 +17220,13 @@ function parseLoadableModuleArgs(argv)
{ {
case MAIL_YOUR: // Mail sent to you case MAIL_YOUR: // Mail sent to you
argVals.personalemail = true; argVals.personalemail = true;
argVals.usernum = argv[1]; argVals.usernum = +(argv[1]);
if (newMailOnly) if (newMailOnly)
argVals.onlynewpersonalemail = true; argVals.onlynewpersonalemail = true;
break; break;
case MAIL_SENT: // Mail you have sent case MAIL_SENT: // Mail you have sent
argVals.personalemailsent = true; argVals.personalemailsent = true;
argVals.usernum = argv[1]; argVals.usernum = +(argv[1]);
break; break;
case MAIL_ALL: case MAIL_ALL:
argVals.allpersonalemail = true; argVals.allpersonalemail = true;
......
Digital Distortion Message Reader Digital Distortion Message Reader
Version 1.63 Version 1.64
Release date: 2023-02-01 Release date: 2023-02-09
by by
......
...@@ -5,6 +5,9 @@ Revision History (change log) ...@@ -5,6 +5,9 @@ Revision History (change log)
============================= =============================
Version Date Description Version Date Description
------- ---- ----------- ------- ---- -----------
1.64 2023-02-09 When reading personal email (received or sent), as a
loadable module, now it can allow reading another user's
mail (for the sysop when deleting a user account).
1.63 2023-02-01 Fix for reading colors from the theme file. Also, the 1.63 2023-02-01 Fix for reading colors from the theme file. Also, the
theme file now no longer needs the control character for theme file now no longer needs the control character for
color codes. color codes.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment