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

Merge branch 'dd_msg_reader_show_user_responses_in_tally_info' into 'master'

DDMsgReader: Optionally show users' vote responses (for polls/upvotes/downvotes) when showing tally info (sysop function) with config option showUserResponsesInTallyInfo.  showUserResponsesInTallyInfo (from last commit) removed.

See merge request !529
parents 8e2c638d c6f1c8ff
No related branches found
No related tags found
1 merge request!529DDMsgReader: Optionally show users' vote responses (for polls/upvotes/downvotes) when showing tally info (sysop function) with config option showUserResponsesInTallyInfo. showUserResponsesInTallyInfo (from last commit) removed.
...@@ -108,10 +108,10 @@ subBoardChangeSorting=None ...@@ -108,10 +108,10 @@ subBoardChangeSorting=None
; as they like. Valid values are true or false. ; as they like. Valid values are true or false.
indexedModeNewscanOnlyShowSubsWithNewMsgs=false indexedModeNewscanOnlyShowSubsWithNewMsgs=false
; For messages with upvotes/downvotes, when showing vote tally info (a sysop function), ; For poll messages or messages with upvotes/downvotes, when showing vote tally info
; whether or not to show whose votes are upvotes and whose are downvotes. If false, ; (a sysop function), whether or not to show each users' responses. If false,
; it will just show the names of who voted on the message (and when). ; it will just show the names of who voted on the message (and when).
showWhoUpvotedAndDownvotedInTallyInfo=false showUserResponsesInTallyInfo=false
; The theme file name (for colors, strings, etc.) ; The theme file name (for colors, strings, etc.)
themeFilename=DefaultTheme.cfg themeFilename=DefaultTheme.cfg
...@@ -244,11 +244,11 @@ ...@@ -244,11 +244,11 @@
* Fix: For the sysop reading personal email addressed to * Fix: For the sysop reading personal email addressed to
* "sysop", mark the email as read * "sysop", mark the email as read
* 2025-04-19 Eric Oulashin Version 1.96p * 2025-04-19 Eric Oulashin Version 1.96p
* When viewing tally information for a message (a sysop * When viewing tally/vote information for a message (a
* feature), DDMsgReader can now optionally show who * sysop feature), DDMsgReader can now optionally show
* specifically voted up/down. Defaults to false. The * users' specific answers (in addition to just showing
* option can be toggled (true/false) via the new * who voted on the message/poll), via the new
* configuration option showWhoUpvotedAndDownvotedInTallyInfo * configuration option showUserResponsesInTallyInfo
*/ */
   
"use strict"; "use strict";
...@@ -1021,7 +1021,7 @@ function DigDistMsgReader(pSubBoardCode, pScriptArgs) ...@@ -1021,7 +1021,7 @@ function DigDistMsgReader(pSubBoardCode, pScriptArgs)
this.ForwardMessage = DigDistMsgReader_ForwardMessage; this.ForwardMessage = DigDistMsgReader_ForwardMessage;
this.VoteOnMessage = DigDistMsgReader_VoteOnMessage; this.VoteOnMessage = DigDistMsgReader_VoteOnMessage;
this.HasUserVotedOnMsg = DigDistMsgReader_HasUserVotedOnMsg; this.HasUserVotedOnMsg = DigDistMsgReader_HasUserVotedOnMsg;
this.GetUpvoteAndDownvoteInfo = DigDistMsgReader_GetUpvoteAndDownvoteInfo; this.GetVoteResponseInfo = DigDistMsgReader_GetVoteResponseInfo;
this.GetMsgBody = DigDistMsgReader_GetMsgBody; this.GetMsgBody = DigDistMsgReader_GetMsgBody;
this.RefreshMsgHdrInArrays = DigDistMsgReader_RefreshMsgHdrInArrays; this.RefreshMsgHdrInArrays = DigDistMsgReader_RefreshMsgHdrInArrays;
this.WriteLightbarKeyHelpMsg = DigDistMsgReader_WriteLightbarKeyHelpMsg; this.WriteLightbarKeyHelpMsg = DigDistMsgReader_WriteLightbarKeyHelpMsg;
...@@ -1104,10 +1104,10 @@ function DigDistMsgReader(pSubBoardCode, pScriptArgs) ...@@ -1104,10 +1104,10 @@ function DigDistMsgReader(pSubBoardCode, pScriptArgs)
// This is like the stock Synchronet behavior. // This is like the stock Synchronet behavior.
this.readingPostOnSubBoardInsteadOfGoToNext = false; this.readingPostOnSubBoardInsteadOfGoToNext = false;
// For messages with upvotes/downvotes, when showing vote tally info (a sysop function), // For poll messages or messages with upvotes/downvotes, when showing vote tally info
// whether or not to show whose votes are upvotes and whose are downvotes. If false, // (a sysop function), whether or not to show each users' responses. If false,
// it will just show the names of who voted on the message (and when). // it will just show the names of who voted on the message (and when).
this.showWhoUpvotedAndDownvotedInTallyInfo = false; this.showUserResponsesInTallyInfo = false;
   
// String lengths for the columns to write // String lengths for the columns to write
// Fixed field widths: Message number, date, and time // Fixed field widths: Message number, date, and time
...@@ -7245,7 +7245,7 @@ function DigDistMsgReader_ShowVoteInfo_Scrollable(pMsgHeader, pMsgAreaWidth, pMs ...@@ -7245,7 +7245,7 @@ function DigDistMsgReader_ShowVoteInfo_Scrollable(pMsgHeader, pMsgAreaWidth, pMs
var originalCurPos = console.getxy(); var originalCurPos = console.getxy();
if (retObj.hasVoteProps) if (retObj.hasVoteProps)
{ {
var voteInfo = this.GetUpvoteAndDownvoteInfo(pMsgHeader); var voteInfo = this.GetVoteResponseInfo(pMsgHeader);
// Display the vote info and let the user scroll through them // Display the vote info and let the user scroll through them
// (the console height should be enough, but do this just in case) // (the console height should be enough, but do this just in case)
// Calculate information for the scrollbar for the vote info lines // Calculate information for the scrollbar for the vote info lines
...@@ -8107,7 +8107,7 @@ function DigDistMsgReader_ReadMessageEnhanced_Traditional(msgHeader, allowChgMsg ...@@ -8107,7 +8107,7 @@ function DigDistMsgReader_ReadMessageEnhanced_Traditional(msgHeader, allowChgMsg
{ {
console.attributes = "N"; console.attributes = "N";
console.crlf(); console.crlf();
var voteInfo = this.GetUpvoteAndDownvoteInfo(msgHeader); var voteInfo = this.GetVoteResponseInfo(msgHeader);
for (var voteInfoIdx = 0; voteInfoIdx < voteInfo.length; ++voteInfoIdx) for (var voteInfoIdx = 0; voteInfoIdx < voteInfo.length; ++voteInfoIdx)
{ {
console.print(voteInfo[voteInfoIdx]); console.print(voteInfo[voteInfoIdx]);
...@@ -8415,7 +8415,7 @@ function DigDistMsgReader_ReadMessageEnhanced_Traditional(msgHeader, allowChgMsg ...@@ -8415,7 +8415,7 @@ function DigDistMsgReader_ReadMessageEnhanced_Traditional(msgHeader, allowChgMsg
{ {
console.attributes = "N"; console.attributes = "N";
console.crlf(); console.crlf();
var voteInfo = this.GetUpvoteAndDownvoteInfo(msgHeader); var voteInfo = this.GetVoteResponseInfo(msgHeader);
for (var voteInfoIdx = 0; voteInfoIdx < voteInfo.length; ++voteInfoIdx) for (var voteInfoIdx = 0; voteInfoIdx < voteInfo.length; ++voteInfoIdx)
{ {
console.print(voteInfo[voteInfoIdx]); console.print(voteInfo[voteInfoIdx]);
...@@ -9995,8 +9995,8 @@ function DigDistMsgReader_ReadConfigFile() ...@@ -9995,8 +9995,8 @@ function DigDistMsgReader_ReadConfigFile()
this.prependFowardMsgSubject = settingsObj.prependFowardMsgSubject; this.prependFowardMsgSubject = settingsObj.prependFowardMsgSubject;
if (typeof(settingsObj.enableIndexedModeMsgListCache) === "boolean") if (typeof(settingsObj.enableIndexedModeMsgListCache) === "boolean")
this.enableIndexedModeMsgListCache = settingsObj.enableIndexedModeMsgListCache; this.enableIndexedModeMsgListCache = settingsObj.enableIndexedModeMsgListCache;
if (typeof(settingsObj.showWhoUpvotedAndDownvotedInTallyInfo) === "boolean") if (typeof(settingsObj.showUserResponsesInTallyInfo) === "boolean")
this.showWhoUpvotedAndDownvotedInTallyInfo = settingsObj.showWhoUpvotedAndDownvotedInTallyInfo; this.showUserResponsesInTallyInfo = settingsObj.showUserResponsesInTallyInfo;
if (typeof(settingsObj.themeFilename) === "string") if (typeof(settingsObj.themeFilename) === "string")
{ {
// First look for the theme config file in the sbbs/mods // First look for the theme config file in the sbbs/mods
...@@ -18982,8 +18982,9 @@ function DigDistMsgReader_HasUserVotedOnMsg(pMsgNum, pUser) ...@@ -18982,8 +18982,9 @@ function DigDistMsgReader_HasUserVotedOnMsg(pMsgNum, pUser)
return userHasVotedOnMsg; return userHasVotedOnMsg;
} }
   
// Gets information about the upvotes and downvotes for a message. // Gets tally information about the votes for a message.
// If the user is a sysop, this will also get who voted on the message. // If the user is a sysop, this will also get who voted on the message
// and optionally, how they voted.
// //
// Parameters: // Parameters:
// pMsgHdr: A header of a message that has upvotes & downvotes // pMsgHdr: A header of a message that has upvotes & downvotes
...@@ -18991,7 +18992,7 @@ function DigDistMsgReader_HasUserVotedOnMsg(pMsgNum, pUser) ...@@ -18991,7 +18992,7 @@ function DigDistMsgReader_HasUserVotedOnMsg(pMsgNum, pUser)
// Return value: An array of strings containing information about the upvotes, // Return value: An array of strings containing information about the upvotes,
// downvotes, tally, and (if the user is a sysop) who submitted // downvotes, tally, and (if the user is a sysop) who submitted
// votes on the message. // votes on the message.
function DigDistMsgReader_GetUpvoteAndDownvoteInfo(pMsgHdr) function DigDistMsgReader_GetVoteResponseInfo(pMsgHdr)
{ {
// If the message header doesn't have the "total_votes" or "upvotes" properties, // If the message header doesn't have the "total_votes" or "upvotes" properties,
// then there's no vote information, so just return an empty array. // then there's no vote information, so just return an empty array.
...@@ -19030,13 +19031,50 @@ function DigDistMsgReader_GetUpvoteAndDownvoteInfo(pMsgHdr) ...@@ -19030,13 +19031,50 @@ function DigDistMsgReader_GetUpvoteAndDownvoteInfo(pMsgHdr)
var tmpMessageBody = msgbase.get_msg_body(false, tmpHdrs[tmpProp].number, false, false, true, true); var tmpMessageBody = msgbase.get_msg_body(false, tmpHdrs[tmpProp].number, false, false, true, true);
var msgIsUpvote = Boolean(tmpHdrs[tmpProp].attr & MSG_UPVOTE); var msgIsUpvote = Boolean(tmpHdrs[tmpProp].attr & MSG_UPVOTE);
var msgIsDownvote = Boolean(tmpHdrs[tmpProp].attr & MSG_DOWNVOTE); var msgIsDownvote = Boolean(tmpHdrs[tmpProp].attr & MSG_DOWNVOTE);
if (tmpHdrs[tmpProp].field_list.length == 0 && tmpMessageBody.length == 0 && (msgIsUpvote || msgIsDownvote)) if (tmpHdrs[tmpProp].field_list.length == 0 && tmpMessageBody.length == 0)
{ {
var msgWrittenLocalTime = msgWrittenTimeToLocalBBSTime(tmpHdrs[tmpProp]); var msgWrittenLocalTime = msgWrittenTimeToLocalBBSTime(tmpHdrs[tmpProp]);
var voteDate = strftime("%a %b %d %Y %H:%M:%S", msgWrittenLocalTime); var voteDate = strftime("%a %b %d %Y %H:%M:%S", msgWrittenLocalTime);
if (Boolean(pMsgHdr.attr & MSG_POLL))
{
// This is a poll
var infoStr = format("\x01n\x01c\x01h%s\x01n\x01c voted on this message on %s\x01n",
tmpHdrs[tmpProp].from, voteDate);
voteInfo.push(infoStr);
// If the option to show the users' specific responses is enabled, then include that
if (this.showUserResponsesInTallyInfo)
{
var answerBitIdx = 0;
for (var fieldI = 0; fieldI < pMsgHdr.field_list.length; ++fieldI)
{
if (pMsgHdr.field_list[fieldI].type == SMB_POLL_ANSWER)
{
var answerBit = (1 << answerBitIdx);
if ((tmpHdrs[tmpProp].votes & answerBit) == answerBit)
{
var optionStrArray = lfexpand(word_wrap(pMsgHdr.field_list[fieldI].data, console.screen_columns-1, null, false)).split("\r\n");
if (optionStrArray.length > 0)
{
if (optionStrArray[optionStrArray.length-1] == "")
optionStrArray.pop();
voteInfo.push(format(" - %s", optionStrArray[0].substr(0, console.screen_columns-4)));
for (var optStrI = 1; optStrI < optionStrArray.length; ++optStrI)
{
format(" - %s", optionStrArray[optStrI].substr(0, console.screen_columns-4))
}
}
}
++answerBitIdx;
}
}
}
}
else
{
// The message is not a poll.
// If the option to show the users' specific responses is enabled, then include that
var infoStr = ""; var infoStr = "";
// If the option to show the users' specific up/downvotes is enabled, then include that if (this.showUserResponsesInTallyInfo)
if (this.showWhoUpvotedAndDownvotedInTallyInfo)
{ {
var voteTypeStr = (msgIsUpvote ? "up" : msgIsDownvote ? "down" : ""); var voteTypeStr = (msgIsUpvote ? "up" : msgIsDownvote ? "down" : "");
infoStr = format("\x01n\x01c\x01h%s\x01n\x01c voted on this message (%s) on %s\x01n", infoStr = format("\x01n\x01c\x01h%s\x01n\x01c voted on this message (%s) on %s\x01n",
...@@ -19051,6 +19089,7 @@ function DigDistMsgReader_GetUpvoteAndDownvoteInfo(pMsgHdr) ...@@ -19051,6 +19089,7 @@ function DigDistMsgReader_GetUpvoteAndDownvoteInfo(pMsgHdr)
} }
} }
} }
}
msgbase.close(); msgbase.close();
} }
} }
...@@ -119,7 +119,7 @@ function doMainMenu() ...@@ -119,7 +119,7 @@ function doMainMenu()
"promptDelPersonalEmailAfterReply", // Boolean "promptDelPersonalEmailAfterReply", // Boolean
"subBoardChangeSorting", // String: None, Alphabetical, LatestMsgDateOldestFirst, or LatestMsgDateNewestFirst "subBoardChangeSorting", // String: None, Alphabetical, LatestMsgDateOldestFirst, or LatestMsgDateNewestFirst
"indexedModeNewscanOnlyShowSubsWithNewMsgs", // Boolean "indexedModeNewscanOnlyShowSubsWithNewMsgs", // Boolean
"showWhoUpvotedAndDownvotedInTallyInfo", // Boolean "showUserResponsesInTallyInfo", // Boolean
"themeFilename" // String "themeFilename" // String
]; ];
// Strings for the options to display on the menu // Strings for the options to display on the menu
...@@ -156,7 +156,7 @@ function doMainMenu() ...@@ -156,7 +156,7 @@ function doMainMenu()
"Personal email: Prompt to delete after reply", "Personal email: Prompt to delete after reply",
"Sorting for sub-board change", "Sorting for sub-board change",
"Index newscan: Only show subs w/ new msgs", "Index newscan: Only show subs w/ new msgs",
"Include specific up/downvotes w/ tally info", "Include user responses in tally info",
"Theme Filename" "Theme Filename"
]; ];
// Build an array of formatted string to be displayed on the menu // Build an array of formatted string to be displayed on the menu
...@@ -637,10 +637,11 @@ function getOptionHelpText() ...@@ -637,10 +637,11 @@ function getOptionHelpText()
optionHelpText["indexedModeNewscanOnlyShowSubsWithNewMsgs"] += "whether to only show sub-boards with new messages. This is a "; optionHelpText["indexedModeNewscanOnlyShowSubsWithNewMsgs"] += "whether to only show sub-boards with new messages. This is a ";
optionHelpText["indexedModeNewscanOnlyShowSubsWithNewMsgs"] += "default for a user setting, which users can change for themselves."; optionHelpText["indexedModeNewscanOnlyShowSubsWithNewMsgs"] += "default for a user setting, which users can change for themselves.";
optionHelpText["showWhoUpvotedAndDownvotedInTallyInfo"] = "Include specific up/downvotes w/ tally info: For messages with upvotes/downvotes, "; optionHelpText["showUserResponsesInTallyInfo"] = "Include user responses in tally info: For poll messages or messages with ";
optionHelpText["showWhoUpvotedAndDownvotedInTallyInfo"] += "when showing vote tally info (a sysop function), whether or not to show whose votes "; optionHelpText["showUserResponsesInTallyInfo"] += "upvotes/downvotes, when showing vote tally info (a sysop function), whether or not ";
optionHelpText["showWhoUpvotedAndDownvotedInTallyInfo"] += "are upvotes and whose are downvotes. If false, it will just show the names of who "; optionHelpText["showUserResponsesInTallyInfo"] += "to show each users' responses. If false, it will just show the names of who voted on ";
optionHelpText["showWhoUpvotedAndDownvotedInTallyInfo"] += "voted on the message (and when)."; optionHelpText["showUserResponsesInTallyInfo"] += "the message (and when).";
optionHelpText["themeFilename"] = "Theme filename: The name of a file for a color theme to use"; optionHelpText["themeFilename"] = "Theme filename: The name of a file for a color theme to use";
...@@ -846,8 +847,8 @@ function readDDMsgReaderCfgFile() ...@@ -846,8 +847,8 @@ function readDDMsgReaderCfgFile()
retObj.cfgOptions.subBoardChangeSorting = "None"; retObj.cfgOptions.subBoardChangeSorting = "None";
if (!retObj.cfgOptions.hasOwnProperty("indexedModeNewscanOnlyShowSubsWithNewMsgs")) if (!retObj.cfgOptions.hasOwnProperty("indexedModeNewscanOnlyShowSubsWithNewMsgs"))
retObj.cfgOptions.indexedModeNewscanOnlyShowSubsWithNewMsgs = false; retObj.cfgOptions.indexedModeNewscanOnlyShowSubsWithNewMsgs = false;
if (!retObj.cfgOptions.hasOwnProperty("showWhoUpvotedAndDownvotedInTallyInfo")) if (!retObj.cfgOptions.hasOwnProperty("showUserResponsesInTallyInfo"))
retObj.cfgOptions.showWhoUpvotedAndDownvotedInTallyInfo = false; retObj.cfgOptions.showUserResponsesInTallyInfo = false;
if (!retObj.cfgOptions.hasOwnProperty("themeFilename")) if (!retObj.cfgOptions.hasOwnProperty("themeFilename"))
retObj.cfgOptions.themeFilename = "DefaultTheme.cfg"; retObj.cfgOptions.themeFilename = "DefaultTheme.cfg";
......
...@@ -853,14 +853,12 @@ indexedModeNewscanOnlyShowSubsWithNewMsgs For indexed-mode newscan, whether to ...@@ -853,14 +853,12 @@ indexedModeNewscanOnlyShowSubsWithNewMsgs For indexed-mode newscan, whether to
for themselves as they like. Valid for themselves as they like. Valid
values are true or false. values are true or false.
showWhoUpvotedAndDownvotedInTallyInfo For messages with upvotes/downvotes, when showUserResponsesInTallyInfo For poll messages or messages with upvotes
showing vote tally info (a sysop and downvotes, when showing vote tally
function), this specifies whether or not info (a sysop function), whether or not to
to show whose votes are upvotes and whose show each users' responses. If false, it
are downvotes. If false, it will just will just show the names of who voted on
show the names of who voted on the the message (and when).
message (and when). Valid values are true
or false.
themeFilename The name of the configuration file to themeFilename The name of the configuration file to
use for colors & string settings use for colors & string settings
......
...@@ -5,11 +5,11 @@ Revision History (change log) ...@@ -5,11 +5,11 @@ Revision History (change log)
============================= =============================
Version Date Description Version Date Description
------- ---- ----------- ------- ---- -----------
1.96p 2025-04-19 When viewing tally information for a message (a sysop 1.96p 2025-04-19 When viewing tally/vote information for a message (a sysop
feature), DDMsgReader can now optionally show who feature), DDMsgReader can now optionally show users'
specifically voted up/down. Defaults to false. The option specific answers (in addition to just showing who voted on
can be toggled (true/false) via the new configuration the message/poll), via the new configuration option
option showWhoUpvotedAndDownvotedInTallyInfo showUserResponsesInTallyInfo
1.96o 2025-04-15 Fix: For the sysop reading personal email addressed to 1.96o 2025-04-15 Fix: For the sysop reading personal email addressed to
"sysop", mark the email as read "sysop", mark the email as read
1.96N 2025-04-13 Changes (fixes) for the bottom-row key help lines due to 1.96N 2025-04-13 Changes (fixes) for the bottom-row key help lines due to
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment