Skip to content
Snippets Groups Projects
Commit f772f0bb authored by nightfox's avatar nightfox
Browse files

Version 1.24: When making a private reply on local email, an error is now...

Version 1.24: When making a private reply on local email, an error is now outputted if the recipient's user number is not found.  Also, fixed an 'undefined' bug that happened when searching for messages sometimes.
parent d0b710ce
No related branches found
No related tags found
No related merge requests found
...@@ -28,6 +28,17 @@ ...@@ -28,6 +28,17 @@
* 2019-07-26 Eric Oulashin Started working on supporting utf-8 text conversion to cp437. * 2019-07-26 Eric Oulashin Started working on supporting utf-8 text conversion to cp437.
* 2019-07-27 Eric Oulashin Version 1.23 * 2019-07-27 Eric Oulashin Version 1.23
* Releasing this version * Releasing this version
* 2019-08-15 Eric Oulashin Version 1.24 Beta
* When making a private reply on local email,
* an error is now outputted if the recipient's
* user number is not found.
* Also, fixed an 'undefined' bug that happened when searching
* for messages sometimes. searchMsgbase() referenced
* this.subBoardCode, but that function isn't
* part of an object, so this.subBoardCode isn't available
* there.
* 2019-08-17 Eric Oulashin Verison 1.24
* Releasing this version
*/ */
   
/* 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
...@@ -125,8 +136,8 @@ if (system.version_num < 31500) ...@@ -125,8 +136,8 @@ if (system.version_num < 31500)
} }
   
// Reader version information // Reader version information
var READER_VERSION = "1.23"; var READER_VERSION = "1.24";
var READER_DATE = "2019-07-27"; var READER_DATE = "2019-08-17";
   
// 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);
...@@ -1413,18 +1424,31 @@ function DigDistMsgReader_GetMsgIdx(pHdrOrMsgNum) ...@@ -1413,18 +1424,31 @@ function DigDistMsgReader_GetMsgIdx(pHdrOrMsgNum)
msgIdx = -1; msgIdx = -1;
} }
else else
msgIdx = msgNumToIdxFromMsgbase(this.subBoardCode, msgNum);
return msgIdx;
}
// Given a sub-board code and message number, this function gets the index
// of that message from the Synchronet messagebase. Returns -1 if not found.
//
// Parameters:
// pSubCode: The sub-board code
// pMsgNum: The message number
//
// Return value: The index of the message, or -1 if not found.
function msgNumToIdxFromMsgbase(pSubCode, pMsgNum)
{
var msgIdx = -1;
var msgbase = new MsgBase(pSubCode);
if (msgbase.open())
{ {
var msgbase = new MsgBase(this.subBoardCode); var msgHdr = msgbase.get_msg_header(false, pMsgNum, false);
if (msgbase.open()) if (msgHdr != null)
{ msgIdx = msgHdr.offset;
var msgHdr = msgbase.get_msg_header(false, msgNum, false); msgbase.close();
if (msgHdr != null)
msgIdx = msgHdr.offset;
msgbase.close();
}
else
msgIdx = -1;
} }
return msgIdx; return msgIdx;
} }
   
...@@ -1575,8 +1599,8 @@ function DigDistMsgReader_SearchMessages(pSearchModeStr, pSubBoardCode) ...@@ -1575,8 +1599,8 @@ function DigDistMsgReader_SearchMessages(pSearchModeStr, pSubBoardCode)
} }
else else
{ {
// List/read messages //this.ReadOrListSubBoard(pSubBoardCode);
this.ReadOrListSubBoard(pSubBoardCode); this.ReadOrListSubBoard(subCode);
// Clear the search data so that subsequent listing or reading sessions // Clear the search data so that subsequent listing or reading sessions
// don't repeat the same search // don't repeat the same search
this.ClearSearchData(); this.ClearSearchData();
...@@ -9124,9 +9148,10 @@ function DigDistMsgReader_ReplyToMsg(pMsgHdr, pMsgText, pPrivate, pMsgIdx) ...@@ -9124,9 +9148,10 @@ function DigDistMsgReader_ReplyToMsg(pMsgHdr, pMsgText, pPrivate, pMsgIdx)
// the user replied to it // the user replied to it
function DigDistMsgReader_DoPrivateReply(pMsgHdr, pMsgIdx, pReplyMode) function DigDistMsgReader_DoPrivateReply(pMsgHdr, pMsgIdx, pReplyMode)
{ {
var retObj = new Object(); var retObj = {
retObj.sendSucceeded = true; sendSucceeded: true,
retObj.msgWasDeleted = false; msgWasDeleted: false
};
if (pMsgHdr == null) if (pMsgHdr == null)
{ {
...@@ -9176,8 +9201,9 @@ function DigDistMsgReader_DoPrivateReply(pMsgHdr, pMsgIdx, pReplyMode) ...@@ -9176,8 +9201,9 @@ function DigDistMsgReader_DoPrivateReply(pMsgHdr, pMsgIdx, pReplyMode)
{ {
retObj.sendSucceeded = false; retObj.sendSucceeded = false;
console.crlf(); console.crlf();
console.print("\1n\1h\1yThere is no network address for this message"); console.print("\1n\1h\1yThere is no network address for this message\1n");
console.crlf(); console.crlf();
console.pause();
} }
} }
else else
...@@ -9185,7 +9211,7 @@ function DigDistMsgReader_DoPrivateReply(pMsgHdr, pMsgIdx, pReplyMode) ...@@ -9185,7 +9211,7 @@ function DigDistMsgReader_DoPrivateReply(pMsgHdr, pMsgIdx, pReplyMode)
// Replying to a local user // Replying to a local user
replyMode |= WM_EMAIL; replyMode |= WM_EMAIL;
// Look up the user number of the "from" user name in the message header // Look up the user number of the "from" user name in the message header
var userNumber = system.matchuser(pMsgHdr.from); var userNumber = findUserNumWithName(pMsgHdr.from); // Used to use system.matchuser(pMsgHdr.from)
if (userNumber != 0) if (userNumber != 0)
{ {
// Output a newline to avoid ugly overwriting of text on the screen in // Output a newline to avoid ugly overwriting of text on the screen in
...@@ -9196,6 +9222,14 @@ function DigDistMsgReader_DoPrivateReply(pMsgHdr, pMsgIdx, pReplyMode) ...@@ -9196,6 +9222,14 @@ function DigDistMsgReader_DoPrivateReply(pMsgHdr, pMsgIdx, pReplyMode)
retObj.sendSucceeded = bbs.email(userNumber, replyMode, "", pMsgHdr.subject); retObj.sendSucceeded = bbs.email(userNumber, replyMode, "", pMsgHdr.subject);
console.pause(); console.pause();
} }
else
{
retObj.sendSucceeded = false;
console.crlf();
console.print("\1n\1h\1yThe recipient (\1w" + pMsgHdr.from + "\1y) was not found\1n");
console.crlf();
console.pause();
}
} }
   
// If the user replied to a personal email, then ask the user if they want // If the user replied to a personal email, then ask the user if they want
...@@ -15906,8 +15940,9 @@ function canDoHighASCIIAndANSI() ...@@ -15906,8 +15940,9 @@ function canDoHighASCIIAndANSI()
// 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)
{ {
var msgHeaders = new Object(); var msgHeaders = {
msgHeaders.indexed = new Array(); indexed: []
};
if ((pSubCode != "mail") && ((typeof(pSearchString) != "string") || !searchTypePopulatesSearchResults(pSearchType))) if ((pSubCode != "mail") && ((typeof(pSearchString) != "string") || !searchTypePopulatesSearchResults(pSearchType)))
return msgHeaders; return msgHeaders;
   
...@@ -16051,12 +16086,12 @@ function searchMsgbase(pSubCode, pSearchType, pSearchString, pListingPersonalEma ...@@ -16051,12 +16086,12 @@ function searchMsgbase(pSubCode, pSearchType, pSearchString, pListingPersonalEma
// Get the offset of the last read message and compare it with the // Get the offset of the last read message and compare it with the
// offset of the given message header // offset of the given message header
var lastReadMsgHdr = pMsgBase.get_msg_header(false, msg_area.sub[pSubBoardCode].last_read, false); var lastReadMsgHdr = pMsgBase.get_msg_header(false, msg_area.sub[pSubBoardCode].last_read, false);
//var lastReadMsgOffset = (lastReadMsgHdr != null ? lastReadMsgHdr.offset : 0); var lastReadMsgOffset = 0;
var lastReadMsgOffset = (lastReadMsgHdr != null ? this.GetMsgIdx(lastReadMsgHdr.number) : 0); if (lastReadMsgHdr != null)
lastReadMsgOffset = msgNumToIdxFromMsgbase(pSubBoardCode, lastReadMsgHdr.number);
if (lastReadMsgOffset < 0) if (lastReadMsgOffset < 0)
lastReadMsgOffset = 0; lastReadMsgOffset = 0;
//return (pMsgHdr.offset > lastReadMsgOffset); return (msgNumToIdxFromMsgbase(pSubBoardCode, pMsgHdr.number) > lastReadMsgOffset);
return (this.GetMsgIdx(pMsgHdr.number) > lastReadMsgOffset);
} }
break; break;
} }
...@@ -16092,7 +16127,7 @@ function searchMsgbase(pSubCode, pSearchType, pSearchString, pListingPersonalEma ...@@ -16092,7 +16127,7 @@ function searchMsgbase(pSubCode, pSearchType, pSearchString, pListingPersonalEma
{ {
// Only add the message header if the message is readable to the user // Only add the message header if the message is readable to the user
// and msgIdx is within bounds // and msgIdx is within bounds
if ((msgIdx >= startMsgIndex) && (msgIdx < endMsgIndex) && isReadableMsgHdr(tmpHdrs[prop], this.subBoardCode)) if ((msgIdx >= startMsgIndex) && (msgIdx < endMsgIndex) && isReadableMsgHdr(tmpHdrs[prop], pSubCode))
{ {
if (tmpHdrs[prop] != null) if (tmpHdrs[prop] != null)
{ {
...@@ -19465,6 +19500,22 @@ function removeInitialColorFromMsgBody(pMsgBody) ...@@ -19465,6 +19500,22 @@ function removeInitialColorFromMsgBody(pMsgBody)
return msgBody; return msgBody;
} }
   
// Finds a user with a name, alias, or handle matching a given string.
// If system.matchuser() can't find it, this will iterate through all users
// to find the first user with a name, alias, or handle matching the given
// name.
function findUserNumWithName(pName)
{
var userNum = system.matchuser(pName);
if (userNum == 0)
userNum = system.matchuserdata(U_NAME, pName);
if (userNum == 0)
userNum = system.matchuserdata(U_ALIAS, pName);
if (userNum == 0)
userNum = system.matchuserdata(U_HANDLE, pName);
return userNum;
}
// For debugging: Writes some text on the screen at a given location with a given pause. // For debugging: Writes some text on the screen at a given location with a given pause.
// //
// Parameters: // Parameters:
...@@ -19492,4 +19543,3 @@ function writeWithPause(pX, pY, pText, pPauseMS, pClearLineAttrib, pClearLineAft ...@@ -19492,4 +19543,3 @@ function writeWithPause(pX, pY, pText, pPauseMS, pClearLineAttrib, pClearLineAft
console.cleartoeol(clearLineAttrib); console.cleartoeol(clearLineAttrib);
} }
} }
Digital Distortion Message Reader Digital Distortion Message Reader
Version 1.23 Version 1.24
Release date: 2019-07-27 Release date: 2019-08-17
by by
......
...@@ -5,6 +5,10 @@ Revision History (change log) ...@@ -5,6 +5,10 @@ Revision History (change log)
============================= =============================
Version Date Description Version Date Description
------- ---- ----------- ------- ---- -----------
1.24 2019-08-17 When making a private reply on local email, an error is
now outputted if the recipient's user number is not
found. Also, fixed an 'undefined' bug that happened when
searching for messages sometimes.
1.23 2019-07-27 If a message is in UTF-8 format and the user's terminal 1.23 2019-07-27 If a message is in UTF-8 format and the user's terminal
doesn't support UTF-8, the message text will be converted doesn't support UTF-8, the message text will be converted
to CP437. Also, if there is a color/attribute code in to CP437. Also, if there is a color/attribute code in
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment