Changeset

5999:9db6bad7cc36

merge
author Stephen Paul Weber <singpolyma@singpolyma.net>
date Wed, 16 Oct 2024 09:30:02 -0500
parents 5998:fd1927e51791 (current diff) 5997:d3812826c1cd (diff)
children 6000:51b6a10b50d2
files
diffstat 6 files changed, 121 insertions(+), 79 deletions(-) [+]
line wrap: on
line diff
--- a/mod_csi_muc_priorities/README.markdown	Tue Oct 08 10:24:39 2024 -0500
+++ b/mod_csi_muc_priorities/README.markdown	Wed Oct 16 09:30:02 2024 -0500
@@ -1,7 +1,7 @@
 # Introduction
 
 This module lets users specify which of the group chats they are in are
-less important. This influences when
+more or less important. This influences when
 [mod_csi_simple][doc:modules:mod_csi_simple] decides to send
 stanzas vs waiting until there is more to send. Users in many large
 public channels might benefit from this.
@@ -12,16 +12,17 @@
 chat priorities* that should appear in the menus of compatible clients.
 
 The command presents a form that accepts a list of XMPP addresses.
-Currently there is a single priority, *Lower priority*, which is
-suitable for e.g. noisy public channels. mod_csi_simple considers
-groupchat messages important by default on the assumptions that smaller
-and more important private chats are more common among most users.
+Currently you can specify channels as lower priority (which is suitable
+for e.g. noisy public channels) or higher priority (which is suitable
+for e.g. small private channels where immediate message delivery is
+desired).  You can also specify whether mucs default to lower priority
+or not.
 
-A message of type groupchat from an address in this list will not be
-considered important enough to send it to an inactive client, unless it
-is from the current user or mentions of their nickname. **Note** that
-mention support require the separate module [mod_track_muc_joins]
-to also be loaded.
+A message of type groupchat from an address in the low priority list will
+not be considered important enough to send it to an inactive client,
+unless it is from the current user or mentions of their nickname.
+**Note** that mention support require the separate module
+[mod_track_muc_joins] to also be loaded.
 
 ``` {.lua}
 modules_enabled = {
--- a/mod_csi_muc_priorities/mod_csi_muc_priorities.lua	Tue Oct 08 10:24:39 2024 -0500
+++ b/mod_csi_muc_priorities/mod_csi_muc_priorities.lua	Wed Oct 16 09:30:02 2024 -0500
@@ -12,14 +12,6 @@
 			local username = session.username;
 			local priorities = user_sessions[username].csi_muc_priorities;
 
-			if priorities then
-				local priority = priorities[room_jid];
-				if priority ~= nil then
-					event.reason = "muc priority";
-					return priority;
-				end
-			end
-
 			-- Look for mention
 			local rooms = session.rooms_joined;
 			if rooms then
@@ -33,12 +25,33 @@
 					end
 					-- Your own messages
 					if stanza.attr.from == (room_jid .. "/" .. room_nick) then
-					event.reason = "muc own message";
+						event.reason = "muc own message";
 						return true;
 					end
 				end
 			end
 
+			-- No mentions found, check other logic:
+			--			deflaultlow=f or nil	defaultlow=t
+			--	in high prio	nil			nil
+			--	in low prio	false			false
+			--	not in either	nil			false
+			--
+			--	true	means:	important (always send immediately)
+			--	nil	means:	normal (respect other mods for stuff like grace period/reactions/etc)
+			--	false	means:	unimportant (delay sending)
+			if priorities then
+				local priority = priorities[room_jid];
+				if priority == false then  -- low priority
+					event.reason = "muc priority";
+					return false;
+				end
+				if priorities[false] and priorities[false]["defaultlow"] and not priority then -- defaultlow is false or nil or not high priority
+					event.reason = "muc user default low";
+					return false;
+				end
+			end
+
 			-- Standard importance and no mention, leave to other modules to decide for now
 			return nil;
 		end
@@ -74,6 +87,12 @@
 		label = "Lower priority";
 		desc = "E.g. large noisy public channels";
 	};
+	{
+		type = "boolean";
+		name = "defaultlow";
+		label = "Default to lower priority";
+		desc = "Mark all channels lower priority as default";
+	};
 }
 
 local store = module:open_store();
@@ -87,20 +106,29 @@
 	local prioritized_jids = user_sessions[username].csi_muc_priorities or store:get(username);
 	local important = {};
 	local unimportant = {};
+	local defaultlow = false; -- Default to high priority
 	if prioritized_jids then
 		for jid, priority in pairs(prioritized_jids) do
-			if priority then
-				table.insert(important, jid);
-			else
-				table.insert(unimportant, jid);
+			if jid then
+				if priority then
+					table.insert(important, jid);
+				else
+					table.insert(unimportant, jid);
+				end
 			end
 		end
 		table.sort(important);
 		table.sort(unimportant);
+
+		if prioritized_jids[false] then
+			defaultlow = prioritized_jids[false]["defaultlow"];
+		end
 	end
+
 	return {
 		important = important;
 		unimportant = unimportant;
+		defaultlow = defaultlow
 	};
 end, function(fields, form_err, data)
 	if form_err then
@@ -118,6 +146,9 @@
 		end
 	end
 
+	local misc_data = {defaultlow = fields.defaultlow};
+	prioritized_jids[false] = misc_data;
+
 	local username = jid_split(data.from);
 	local ok, err = store:set(username, prioritized_jids);
 	if ok then
--- a/mod_http_index/README.markdown	Tue Oct 08 10:24:39 2024 -0500
+++ b/mod_http_index/README.markdown	Wed Oct 16 09:30:02 2024 -0500
@@ -1,3 +1,13 @@
+---
+summary: Generate an index of local HTTP services
+labels:
+- Stage-Beta
+rockspec:
+  build:
+    copy_directories:
+    - html
+---
+
 Introduction
 ============
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_http_index/html/http_index.html	Wed Oct 16 09:30:02 2024 -0500
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<meta name="generator" value="prosody/{prosody_version} mod_{mod_name}">
+<link rel="canonical" href="{canonical}">
+<title>{title}</title>
+<style>
+:link,:visited{color:#3465a4;text-decoration:none;}
+:link:hover,:visited:hover{color:#6197df;}
+body{background-color:#eeeeec;margin:1ex 0;padding-bottom:3em;font-family:Arial,Helvetica,sans-serif;}
+ul,ol{padding:0;}
+li{list-style:none;}
+hr{visibility:hidden;clear:both;}
+br{clear:both;}
+header,footer{margin:1ex 1em;}
+footer{font-size:smaller;color:#babdb6;}
+nav{font-size:large;margin:1ex 1ex;clear:both;line-height:1.5em;}
+footer nav .up{display:none;}
+@media screen and (min-width: 460px) {
+nav {font-size:x-large;margin:1ex 1em;}
+}
+nav a{padding:1ex}
+nav li,nav dt{margin:1ex}
+.content{background-color:white;padding:1em;list-style-position:inside;}
+@media (prefers-color-scheme: dark) {
+html{color:#eee}
+body{background-color:#161616}
+.content{background-color:#1c1c1c}
+footer{color:#444}
+}
+</style>
+</head>
+<body>
+<header>
+<h1>Prosody IM</h1>
+<h2>HTTP Services</h2>
+</header>
+<hr>
+<div class="content">
+<nav>
+<ul>{items#
+<li><a href="{item.url}" title="{item.module}">{item.title?{item.name}}</a></li>}
+</ul>
+</nav>
+</div>
+<hr>
+<footer>
+<br>
+<div class="powered-by">Prosody {prosody_version?}</div>
+</footer>
+</body>
+</html>
--- a/mod_http_index/http_index.html	Tue Oct 08 10:24:39 2024 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<meta charset="utf-8">
-<meta name="viewport" content="width=device-width, initial-scale=1">
-<meta name="generator" value="prosody/{prosody_version} mod_{mod_name}">
-<link rel="canonical" href="{canonical}">
-<title>{title}</title>
-<style>
-:link,:visited{color:#3465a4;text-decoration:none;}
-:link:hover,:visited:hover{color:#6197df;}
-body{background-color:#eeeeec;margin:1ex 0;padding-bottom:3em;font-family:Arial,Helvetica,sans-serif;}
-ul,ol{padding:0;}
-li{list-style:none;}
-hr{visibility:hidden;clear:both;}
-br{clear:both;}
-header,footer{margin:1ex 1em;}
-footer{font-size:smaller;color:#babdb6;}
-nav{font-size:large;margin:1ex 1ex;clear:both;line-height:1.5em;}
-footer nav .up{display:none;}
-@media screen and (min-width: 460px) {
-nav {font-size:x-large;margin:1ex 1em;}
-}
-nav a{padding:1ex}
-nav li,nav dt{margin:1ex}
-.content{background-color:white;padding:1em;list-style-position:inside;}
-@media (prefers-color-scheme: dark) {
-html{color:#eee}
-body{background-color:#161616}
-.content{background-color:#1c1c1c}
-footer{color:#444}
-}
-</style>
-</head>
-<body>
-<header>
-<h1>Prosody IM</h1>
-<h2>HTTP Services</h2>
-</header>
-<hr>
-<div class="content">
-<nav>
-<ul>{items#
-<li><a href="{item.url}" title="{item.module}">{item.title?{item.name}}</a></li>}
-</ul>
-</nav>
-</div>
-<hr>
-<footer>
-<br>
-<div class="powered-by">Prosody {prosody_version?}</div>
-</footer>
-</body>
-</html>
--- a/mod_http_index/mod_http_index.lua	Tue Oct 08 10:24:39 2024 -0500
+++ b/mod_http_index/mod_http_index.lua	Wed Oct 16 09:30:02 2024 -0500
@@ -7,8 +7,8 @@
 
 local base_template;
 do
-	local template_file = module:get_option_string(module.name .. "_template", module.name .. ".html");
-	template_file = assert(module:load_resource(template_file));
+	local template_file = module:get_option_path(module.name .. "_template", "html/" .. module.name .. ".html");
+	template_file = assert(io.open(template_file));
 	base_template = template_file:read("*a");
 	template_file:close();
 end