mod_muc_markers: Allow configuration of which marker to track, default to displayed
--- a/mod_muc_markers/README.markdown Sun May 17 22:38:55 2020 +0200
+++ b/mod_muc_markers/README.markdown Tue May 19 14:06:42 2020 +0100
@@ -1,6 +1,6 @@
# Introduction
-This module adds an internal Prosody API to retrieve the last received message by MUC occupants.
+This module adds an internal Prosody API to retrieve the last displayed message by MUC occupants.
## Requirements
@@ -26,7 +26,9 @@
## Settings
-There are no configuration options for this module.
+| Name | Description | Default |
+|-----------------|--------------------------------------------------------------|------------|
+| muc_marker_type | The type of marker to track (displayed/received/acknowledged)| "displayed"|
# Developers
@@ -36,6 +38,6 @@
local muc_markers = module:depends("muc_markers");
function something()
- local last_received_id = muc_markers.get_user_read_marker("user@localhost", "room@conference.localhost");
+ local last_displayed_id = muc_markers.get_user_read_marker("user@localhost", "room@conference.localhost");
end
```
--- a/mod_muc_markers/mod_muc_markers.lua Sun May 17 22:38:55 2020 +0200
+++ b/mod_muc_markers/mod_muc_markers.lua Tue May 19 14:06:42 2020 +0100
@@ -10,6 +10,8 @@
local xmlns_markers = "urn:xmpp:chat-markers:0";
+local marker_element_name = module:get_option_string("muc_marker_type", "displayed");
+
local muc_marker_map_store = module:open_store("muc_markers", "map");
local function get_stanza_id(stanza, by_jid)
@@ -35,7 +37,7 @@
end, -1);
module:hook("muc-occupant-groupchat", function (event)
- local marker = event.stanza:get_child("received", xmlns_markers);
+ local marker = event.stanza:get_child(marker_element_name, xmlns_markers);
if not marker then return; end
-- Store the id that the user has received to