From 47f5f3043d485c5056b60f4092ba66e47cf7810d Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 17 Jan 2019 01:04:39 +0100 Subject: mod_presence: Revert empty 'to' attribute of presence before presence/initial event (fixes #1296) --- plugins/mod_presence.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins') diff --git a/plugins/mod_presence.lua b/plugins/mod_presence.lua index 5056a3a3..268a2f0c 100644 --- a/plugins/mod_presence.lua +++ b/plugins/mod_presence.lua @@ -63,6 +63,7 @@ function handle_normal_presence(origin, stanza) core_post_stanza(origin, stanza, true); end end + stanza.attr.to = nil; if stanza.attr.type == nil and not origin.presence then -- initial presence module:fire_event("presence/initial", { origin = origin, stanza = stanza } ); origin.presence = stanza; -- FIXME repeated later -- cgit v1.2.3 From 9fa98ab579800de8d4d51ccc93765ca6cc4ad47b Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 17 Jan 2019 01:05:47 +0100 Subject: mod_motd: Remove redundant conditions The stanza should always be like this in the presence/initial event --- plugins/mod_motd.lua | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_motd.lua b/plugins/mod_motd.lua index 13bc7e31..c68e77a8 100644 --- a/plugins/mod_motd.lua +++ b/plugins/mod_motd.lua @@ -18,12 +18,10 @@ local st = require "util.stanza"; motd_text = motd_text:gsub("^%s*(.-)%s*$", "%1"):gsub("\n[ \t]+", "\n"); -- Strip indentation from the config module:hook("presence/initial", function (event) - local session, stanza = event.origin, event.stanza; - if not stanza.attr.type and not stanza.attr.to then - local motd_stanza = - st.message({ to = session.full_jid, from = motd_jid }) - :tag("body"):text(motd_text); - module:send(motd_stanza); - module:log("debug", "MOTD send to user %s", session.full_jid); - end + local session, stanza = event.origin, event.stanza; + local motd_stanza = + st.message({ to = session.full_jid, from = motd_jid }) + :tag("body"):text(motd_text); + module:send(motd_stanza); + module:log("debug", "MOTD send to user %s", session.full_jid); end, 1); -- cgit v1.2.3