mod_csi_muc_priorities: Reduce importance of group chat messages
This helps if you are in more noisy public channels than small private
group chats.
The short term plan is to give users the ability to set MUC JIDs as
either high or low priority and use that. Long term it would be great to
be able to automatically classify MUCs as public channels vs private
group chats.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_csi_muc_priorities/mod_csi_muc_priorities.lua Mon Apr 01 00:15:13 2019 +0200
@@ -0,0 +1,23 @@
+local jid = require "util.jid";
+
+module:depends"track_muc_joins"
+
+module:hook("csi-is-stanza-important", function (event)
+ local stanza, session = event.stanza, event.session;
+ if stanza.name == "message" then
+ if stanza.attr.type == "groupchat" then
+ local body = stanza:get_child_text("body");
+ if not body then return end
+
+ local rooms = session.rooms_joined;
+ if not rooms then return false; end
+
+ -- TODO optional?
+ local room_nick = rooms[jid.bare(stanza.attr.from)];
+ if room_nick and body:find(room_nick, 1, true) then return true; end
+
+ return false;
+ end
+ end
+end);
+