From 9cde2e34c616d9d681df2c92ff8f7fc952ea680f Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 19 Feb 2017 13:44:47 +0100 Subject: mod_mam: Fix wording of comment --- plugins/mod_mam/mod_mam.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/mod_mam') diff --git a/plugins/mod_mam/mod_mam.lua b/plugins/mod_mam/mod_mam.lua index 81b0690c..d7505f13 100644 --- a/plugins/mod_mam/mod_mam.lua +++ b/plugins/mod_mam/mod_mam.lua @@ -334,7 +334,7 @@ if cleanup_after ~= "never" then -- Iterating over users is not supported by all authentication modules -- Catch and ignore error if not supported pcall(function () - -- If this works, then we schedule cleanup for all known known + -- If this works, then we schedule cleanup for all known users on startup for user in um.users(module.host) do cleanup[user] = true; end -- cgit v1.2.3 From f6dcf5996815a4b93eebb305d85390187cea2bc7 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 19 Feb 2017 23:39:53 +0100 Subject: mod_mam: Strip stanza-id tags after carbons --- plugins/mod_mam/mod_mam.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'plugins/mod_mam') diff --git a/plugins/mod_mam/mod_mam.lua b/plugins/mod_mam/mod_mam.lua index d7505f13..30e416ff 100644 --- a/plugins/mod_mam/mod_mam.lua +++ b/plugins/mod_mam/mod_mam.lua @@ -307,6 +307,19 @@ local function c2s_message_handler(event) return message_handler(event, true); end + +local function strip_stanza_id(event) + local strip_by = jid_bare(event.origin.full_jid); + event.stanza:maptags(function(tag) + if not ( tag.attr.xmlns == xmlns_st_id and tag.attr.by == strip_by ) then + return tag; + end + end); +end + +module:hook("pre-message/bare", strip_stanza_id, -1); +module:hook("pre-message/full", strip_stanza_id, -1); + local cleanup_after = module:get_option_string("archive_expires_after", "1w"); local cleanup_interval = module:get_option_number("archive_cleanup_interval", 4 * 60 * 60); if cleanup_after ~= "never" then -- cgit v1.2.3 From 23f6da0769d408844c0395f8ca78ba3724e755a8 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 20 Feb 2017 00:32:59 +0100 Subject: mod_mam: Update namespace to XEP-0313 v0.6 --- plugins/mod_mam/mamprefsxml.lib.lua | 2 +- plugins/mod_mam/mod_mam.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/mod_mam') diff --git a/plugins/mod_mam/mamprefsxml.lib.lua b/plugins/mod_mam/mamprefsxml.lib.lua index 0598bbcd..8eee78d8 100644 --- a/plugins/mod_mam/mamprefsxml.lib.lua +++ b/plugins/mod_mam/mamprefsxml.lib.lua @@ -10,7 +10,7 @@ -- local st = require"util.stanza"; -local xmlns_mam = "urn:xmpp:mam:1"; +local xmlns_mam = "urn:xmpp:mam:2"; local default_attrs = { always = true, [true] = "always", diff --git a/plugins/mod_mam/mod_mam.lua b/plugins/mod_mam/mod_mam.lua index 30e416ff..7c8dbceb 100644 --- a/plugins/mod_mam/mod_mam.lua +++ b/plugins/mod_mam/mod_mam.lua @@ -9,7 +9,7 @@ -- XEP-0313: Message Archive Management for Prosody -- -local xmlns_mam = "urn:xmpp:mam:1"; +local xmlns_mam = "urn:xmpp:mam:2"; local xmlns_delay = "urn:xmpp:delay"; local xmlns_forward = "urn:xmpp:forward:0"; local xmlns_st_id = "urn:xmpp:sid:0"; -- cgit v1.2.3 From f6b5f2631e8d4ce38d1de8763a7eccbe4f6ff3d9 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 20 Feb 2017 00:37:46 +0100 Subject: mod_mam: Add missing wrapping element when returning the query form --- plugins/mod_mam/mod_mam.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/mod_mam') diff --git a/plugins/mod_mam/mod_mam.lua b/plugins/mod_mam/mod_mam.lua index 7c8dbceb..5e09ec89 100644 --- a/plugins/mod_mam/mod_mam.lua +++ b/plugins/mod_mam/mod_mam.lua @@ -89,7 +89,7 @@ local query_form = dataform { -- Serve form module:hook("iq-get/self/"..xmlns_mam..":query", function(event) local origin, stanza = event.origin, event.stanza; - origin.send(st.reply(stanza):add_child(query_form:form())); + origin.send(st.reply(stanza):query(xmlns_mam):add_child(query_form:form())); return true; end); -- cgit v1.2.3 From 7e36855e9b799d130dd75b5b8f212a8b79f2c8da Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 20 Feb 2017 00:38:32 +0100 Subject: mod_mam: Fix typo in comment --- plugins/mod_mam/mod_mam.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/mod_mam') diff --git a/plugins/mod_mam/mod_mam.lua b/plugins/mod_mam/mod_mam.lua index 5e09ec89..23106ba8 100644 --- a/plugins/mod_mam/mod_mam.lua +++ b/plugins/mod_mam/mod_mam.lua @@ -373,7 +373,7 @@ end -- Stanzas sent by local clients module:hook("pre-message/bare", c2s_message_handler, 0); module:hook("pre-message/full", c2s_message_handler, 0); --- Stanszas to local clients +-- Stanzas to local clients module:hook("message/bare", message_handler, 0); module:hook("message/full", message_handler, 0); -- cgit v1.2.3 From 04f890a467a18c9f29b7cc49ae85a928984d3344 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 20 Feb 2017 00:51:12 +0100 Subject: mod_mam: Remove repeated blank line --- plugins/mod_mam/mod_mam.lua | 2 -- 1 file changed, 2 deletions(-) (limited to 'plugins/mod_mam') diff --git a/plugins/mod_mam/mod_mam.lua b/plugins/mod_mam/mod_mam.lua index 23106ba8..1b935e0e 100644 --- a/plugins/mod_mam/mod_mam.lua +++ b/plugins/mod_mam/mod_mam.lua @@ -134,7 +134,6 @@ module:hook("iq-set/self/"..xmlns_mam..":query", function(event) local before, after = qset and qset.before, qset and qset.after; if type(before) ~= "string" then before = nil; end - -- Load all the data! local data, err = archive:find(origin.username, { start = qstart; ["end"] = qend; -- Time range @@ -307,7 +306,6 @@ local function c2s_message_handler(event) return message_handler(event, true); end - local function strip_stanza_id(event) local strip_by = jid_bare(event.origin.full_jid); event.stanza:maptags(function(tag) -- cgit v1.2.3 From ef1b01c822a6835cd3567885ceba78c7f42d83f7 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 20 Feb 2017 01:26:48 +0100 Subject: mod_mam: Fix to treat first return value from archive:append as assigned ID --- plugins/mod_mam/mod_mam.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'plugins/mod_mam') diff --git a/plugins/mod_mam/mod_mam.lua b/plugins/mod_mam/mod_mam.lua index 1b935e0e..6e6d6383 100644 --- a/plugins/mod_mam/mod_mam.lua +++ b/plugins/mod_mam/mod_mam.lua @@ -291,8 +291,9 @@ local function message_handler(event, c2s) log("debug", "Archiving stanza: %s", stanza:top_tag()); -- And stash it - local ok, id = archive:append(store_user, nil, stanza, time_now(), with); + local ok = archive:append(store_user, nil, stanza, time_now(), with); if ok then + local id = ok; stanza:tag("stanza-id", { xmlns = xmlns_st_id, by = store_user.."@"..host, id = id }):up(); if cleanup then cleanup[store_user] = true; end module:fire_event("archive-message-added", { origin = origin, stanza = stanza, for_user = store_user, id = id }); -- cgit v1.2.3