Skip to content
Snippets Groups Projects
Commit d897d430 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Merge branch 'dd_msg_reader_bbs_edit_msg' into 'master'

DDMsgReader: Now calls bbs.edit_msg() to edit an existing message.

See merge request !167
parents a8db694b 307a7cd5
No related branches found
No related tags found
2 merge requests!463MRC mods by Codefenix (2024-10-20),!167DDMsgReader: Now calls bbs.edit_msg() to edit an existing message.
...@@ -133,6 +133,9 @@ ...@@ -133,6 +133,9 @@
* loadable module by Synchronet (work started on March 8). * loadable module by Synchronet (work started on March 8).
* Also, refactored to use attr_conv.js and removed the * Also, refactored to use attr_conv.js and removed the
* attribute conversion functions from this script. * attribute conversion functions from this script.
* 2022-03-23 Eric Oulashin Version 1.47a
* Now calls bbs.edit_msg() to edit an existing message (if
* that function exists - It was added in Synchronet 3.18).
*/ */
   
// 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
...@@ -250,8 +253,8 @@ if (system.version_num < 31500) ...@@ -250,8 +253,8 @@ if (system.version_num < 31500)
} }
   
// Reader version information // Reader version information
var READER_VERSION = "1.47"; var READER_VERSION = "1.47a";
var READER_DATE = "2022-03-14"; var READER_DATE = "2022-03-23";
   
// 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);
...@@ -832,6 +835,7 @@ function DigDistMsgReader(pSubBoardCode, pScriptArgs) ...@@ -832,6 +835,7 @@ function DigDistMsgReader(pSubBoardCode, pScriptArgs)
this.SetMsgListPauseTextAndLightbarHelpLine = DigDistMsgReader_SetMsgListPauseTextAndLightbarHelpLine; this.SetMsgListPauseTextAndLightbarHelpLine = DigDistMsgReader_SetMsgListPauseTextAndLightbarHelpLine;
this.SetEnhancedReaderHelpLine = DigDistMsgReader_SetEnhancedReaderHelpLine; this.SetEnhancedReaderHelpLine = DigDistMsgReader_SetEnhancedReaderHelpLine;
this.EditExistingMsg = DigDistMsgReader_EditExistingMsg; this.EditExistingMsg = DigDistMsgReader_EditExistingMsg;
this.EditExistingMessageOldWay = DigDistMsgReader_EditExistingMessageOldWay;
this.CanDelete = DigDistMsgReader_CanDelete; this.CanDelete = DigDistMsgReader_CanDelete;
this.CanDeleteLastMsg = DigDistMsgReader_CanDeleteLastMsg; this.CanDeleteLastMsg = DigDistMsgReader_CanDeleteLastMsg;
this.CanEdit = DigDistMsgReader_CanEdit; this.CanEdit = DigDistMsgReader_CanEdit;
...@@ -8114,15 +8118,46 @@ function DigDistMsgReader_EditExistingMsg(pMsgIndex) ...@@ -8114,15 +8118,46 @@ function DigDistMsgReader_EditExistingMsg(pMsgIndex)
return returnObj; return returnObj;
} }
   
// Make use of bbs.edit_msg() if the function exists (it was added in
// Synchronet 3.18c). Otherwise, edit the old way.
if (typeof(bbs.edit_msg) === "function")
{
if (!bbs.edit_msg(msgHeader))
{
var grpIdx = msg_area.sub[this.subBoardCode].grp_index;
var areaDesc = msg_area.grp_list[grpIdx].description + " - " + msg_area.sub[this.subBoardCode].description;
var logMsg = user.alias + " was unable to edit message number " + msgHeader.number + " in " + areaDesc;
log(LOG_ERROR, logMsg);
bbs.log_str(logMsg);
}
}
else
this.EditExistingMessageOldWay(msgbase, msgHeader, pMsgIndex);
msgbase.close();
return returnObj;
}
// Helper for DigDistMsgReader_EditExistingMsg(): Edits an existing message by writing it
// to a temporary file, having the user edit that, and saving it as a new message.
// This was done before the bbs.edit_msg() function existed (it was added in Synchronet
// 3.18c).
//
// Parameters:
// pMsgbase: The MessageBase object. Assumed to be open.
// pOrigMsgHdr: The header of the original message
// pMsgIndex: The index of the message to edit
function DigDistMsgReader_EditExistingMessageOldWay(pMsgbase, pOrigMsgHdr, pMsgIndex)
{
// Dump the message body to a temporary file in the node dir // Dump the message body to a temporary file in the node dir
//var originalMsgBody = msgbase.get_msg_body(true, pMsgIndex, false, false, true, true); //var originalMsgBody = pMsgbase.get_msg_body(true, pMsgIndex, false, false, true, true);
var originalMsgBody; var originalMsgBody;
var tmpMsgHdr = this.GetMsgHdrByIdx(pMsgIndex, false, msgbase); var tmpMsgHdr = this.GetMsgHdrByIdx(pMsgIndex, false, pMsgbase);
var msgHdrIsBogus = (tmpMsgHdr.hasOwnProperty("isBogus") ? tmpMsgHdr.isBogus : false); var msgHdrIsBogus = (tmpMsgHdr.hasOwnProperty("isBogus") ? tmpMsgHdr.isBogus : false);
if (msgHdrIsBogus) if (msgHdrIsBogus)
originalMsgBody = msgbase.get_msg_body(true, pMsgIndex, false, false, true, true); originalMsgBody = pMsgbase.get_msg_body(true, pMsgIndex, false, false, true, true);
else else
originalMsgBody = msgbase.get_msg_body(false, tmpMsgHdr.number, false, false, true, true); originalMsgBody = pMsgbase.get_msg_body(false, tmpMsgHdr.number, false, false, true, true);
var tempFilename = system.node_dir + "DDMsgLister_message.txt"; var tempFilename = system.node_dir + "DDMsgLister_message.txt";
var tmpFile = new File(tempFilename); var tmpFile = new File(tempFilename);
if (tmpFile.open("w")) if (tmpFile.open("w"))
...@@ -8141,15 +8176,15 @@ function DigDistMsgReader_EditExistingMsg(pMsgIndex) ...@@ -8141,15 +8176,15 @@ function DigDistMsgReader_EditExistingMsg(pMsgIndex)
// bbs.msg_number is a unique message identifier that won't // bbs.msg_number is a unique message identifier that won't
// change, so it's probably best for scripts to use bbs.msg_number // change, so it's probably best for scripts to use bbs.msg_number
// instead of offsets. // instead of offsets.
bbs.msg_to = msgHeader.to; bbs.msg_to = pOrigMsgHdr.to;
bbs.msg_to_ext = msgHeader.to_ext; bbs.msg_to_ext = pOrigMsgHdr.to_ext;
bbs.msg_subject = msgHeader.subject; bbs.msg_subject = pOrigMsgHdr.subject;
bbs.msg_offset = msgHeader.offset; bbs.msg_offset = pOrigMsgHdr.offset;
bbs.msg_number = msgHeader.number; bbs.msg_number = pOrigMsgHdr.number;
   
// Let the user edit the temporary file // Let the user edit the temporary file
console.editfile(tempFilename); console.editfile(tempFilename);
// Load the temp file back into msgBodyColor and have msgbase // Load the temp file back into msgBodyColor and have pMsgbase
// save the message. // save the message.
if (tmpFile.open("r")) if (tmpFile.open("r"))
{ {
...@@ -8162,18 +8197,18 @@ function DigDistMsgReader_EditExistingMsg(pMsgIndex) ...@@ -8162,18 +8197,18 @@ function DigDistMsgReader_EditExistingMsg(pMsgIndex)
// aborted out of the message editor.) // aborted out of the message editor.)
if (newMsgBody != originalMsgBody) if (newMsgBody != originalMsgBody)
{ {
var newHdr = { to: msgHeader.to, to_ext: msgHeader.to_ext, from: msgHeader.from, var newHdr = { to: pOrigMsgHdr.to, to_ext: pOrigMsgHdr.to_ext, from: pOrigMsgHdr.from,
from_ext: msgHeader.from_ext, attr: msgHeader.attr, from_ext: pOrigMsgHdr.from_ext, attr: pOrigMsgHdr.attr,
subject: msgHeader.subject }; subject: pOrigMsgHdr.subject };
var savedNewMsg = msgbase.save_msg(newHdr, newMsgBody); var savedNewMsg = pMsgbase.save_msg(newHdr, newMsgBody);
// If the message was successfully saved, then mark the original // If the message was successfully saved, then mark the original
// message for deletion and output a message to the user. // message for deletion and output a message to the user.
if (savedNewMsg) if (savedNewMsg)
{ {
returnObj.msgEdited = true; returnObj.msgEdited = true;
returnObj.newMsgIdx = msgbase.total_msgs - 1; returnObj.newMsgIdx = pMsgbase.total_msgs - 1;
var message = "\1n\1cThe edited message has been saved as a new message."; var message = "\1n\1cThe edited message has been saved as a new message.";
if (msgbase.remove_msg(true, pMsgIndex)) if (pMsgbase.remove_msg(true, pMsgIndex))
message += " The original has been\r\nmarked for deletion."; message += " The original has been\r\nmarked for deletion.";
else else
message += " \1h\1yHowever, the original\r\ncould not be marked for deletion."; message += " \1h\1yHowever, the original\r\ncould not be marked for deletion.";
...@@ -8206,11 +8241,8 @@ function DigDistMsgReader_EditExistingMsg(pMsgIndex) ...@@ -8206,11 +8241,8 @@ function DigDistMsgReader_EditExistingMsg(pMsgIndex)
} }
// Delete the temporary file from disk. // Delete the temporary file from disk.
tmpFile.remove(); tmpFile.remove();
msgbase.close();
return returnObj;
} }
// For the DigDistMsgReader Class: Returns whether or not the user can delete // For the DigDistMsgReader Class: Returns whether or not the user can delete
// their messages in the sub-board (distinct from being able to delete only // their messages in the sub-board (distinct from being able to delete only
// their last message). // their last message).
......
Digital Distortion Message Reader Digital Distortion Message Reader
Version 1.47 Version 1.47a
Release date: 2022-03-14 Release date: 2022-03-23
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.47a 2022-03-23 Internal change: Now calls bbs.edit_msg() for editing an
existing message (for Synchronet 3.18 and up).
Functionally no change.
1.47 2022-03-14 DDMsgReader can now be called directly as a loadable 1.47 2022-03-14 DDMsgReader can now be called directly as a loadable
module by Synchronet (though requires the included module by Synchronet (though requires the included
ddmr_lm.js if DDMsgReader.js is not in sbbs/exec or ddmr_lm.js if DDMsgReader.js is not in sbbs/exec or
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment