aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc/history.lib.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-05-07 22:12:22 +0200
committerKim Alvefur <zash@zash.se>2018-05-07 22:12:22 +0200
commitc9a4b55656cbdb49287a08029ccb96bbed6228e5 (patch)
treeda0694a0dc10c32e33c8ea2f167f8e7853658643 /plugins/muc/history.lib.lua
parent4b973422dd88555a4c8e9e878f006ccbfb2de2fe (diff)
downloadprosody-c9a4b55656cbdb49287a08029ccb96bbed6228e5.tar.gz
prosody-c9a4b55656cbdb49287a08029ccb96bbed6228e5.zip
MUC: Move condition for what gets added to history so that other modules benefit (thanks jcbrand)
This helps mod_muc_mam avoid logging eg chat-state-only messages without needing to implement similar logic in many places
Diffstat (limited to 'plugins/muc/history.lib.lua')
-rw-r--r--plugins/muc/history.lib.lua32
1 files changed, 16 insertions, 16 deletions
diff --git a/plugins/muc/history.lib.lua b/plugins/muc/history.lib.lua
index e467ae32..b816bca7 100644
--- a/plugins/muc/history.lib.lua
+++ b/plugins/muc/history.lib.lua
@@ -138,28 +138,28 @@ end, 50); -- Before subject(20)
-- add to history
module:hook("muc-add-history", function(event)
- local historic = event.stanza:get_child("body");
- if historic then
- local room = event.room
- local history = room._history;
- if not history then history = {}; room._history = history; end
- local stanza = st.clone(event.stanza);
- stanza.attr.to = "";
- local ts = gettime();
- local stamp = datetime.datetime(ts);
- stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = module.host, stamp = stamp}):up(); -- XEP-0203
- stanza:tag("x", {xmlns = "jabber:x:delay", from = module.host, stamp = datetime.legacy()}):up(); -- XEP-0091 (deprecated)
- local entry = { stanza = stanza, timestamp = ts };
- table.insert(history, entry);
- while #history > get_historylength(room) do table.remove(history, 1) end
- end
+ local room = event.room
+ local history = room._history;
+ if not history then history = {}; room._history = history; end
+ local stanza = st.clone(event.stanza);
+ stanza.attr.to = "";
+ local ts = gettime();
+ local stamp = datetime.datetime(ts);
+ stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = module.host, stamp = stamp}):up(); -- XEP-0203
+ stanza:tag("x", {xmlns = "jabber:x:delay", from = module.host, stamp = datetime.legacy()}):up(); -- XEP-0091 (deprecated)
+ local entry = { stanza = stanza, timestamp = ts };
+ table.insert(history, entry);
+ while #history > get_historylength(room) do table.remove(history, 1) end
return true;
end, -1);
-- Have a single muc-add-history event, so that plugins can mark it
-- as handled without stopping other muc-broadcast-message handlers
module:hook("muc-broadcast-message", function(event)
- module:fire_event("muc-add-history", event);
+ local historic = event.stanza:get_child("body");
+ if historic then
+ module:fire_event("muc-add-history", event);
+ end
end);
return {