# HG changeset patch # User Emmanuel Gil Peyrot # Date 1505839638 -7200 # Node ID 314cebb3071e15fd33dcec8a2f125a68ad343732 # Parent 85cf9a8b4020b224cc45db5f3ded23dfde79fbe2 mod_pastebin: Check for MUC presence before handling a message. Fixes #955. diff -r 85cf9a8b4020 -r 314cebb3071e mod_pastebin/mod_pastebin.lua --- a/mod_pastebin/mod_pastebin.lua Mon Sep 18 16:39:02 2017 +0100 +++ b/mod_pastebin/mod_pastebin.lua Tue Sep 19 18:47:18 2017 +0200 @@ -5,6 +5,8 @@ local os_time = os.time; local t_insert, t_remove = table.insert, table.remove; local add_task = require "util.timer".add_task; +local jid_bare = require "util.jid".bare; +local muc_rooms = module:depends "muc".rooms; local utf8_pattern = "[\194-\244][\128-\191]*$"; local function drop_invalid_utf8(seq) @@ -68,6 +70,15 @@ function check_message(data) local origin, stanza = data.origin, data.stanza; + -- Only check for MUC presence when loaded on a component. + if module:get_host_type() == "component" then + local room = muc_rooms[jid_bare(stanza.attr.to)]; + if not room then return; end + + local nick = room._jid_nick[stanza.attr.from]; + if not nick then return; end + end + local body, bodyindex, htmlindex; for k,v in ipairs(stanza) do if v.name == "body" then