mod_muc_mention_notifications/mod_muc_mention_notifications.lua
changeset 4312 2d42dd45638a
parent 4311 af7297e49885
child 4317 fc5c53d9d340
equal deleted inserted replaced
4311:af7297e49885 4312:2d42dd45638a
    10 local mmn_xmlns = "urn:xmpp:mmn:0";
    10 local mmn_xmlns = "urn:xmpp:mmn:0";
    11 local reference_xmlns = "urn:xmpp:reference:0";
    11 local reference_xmlns = "urn:xmpp:reference:0";
    12 local forwarded_xmlns = "urn:xmpp:forward:0";
    12 local forwarded_xmlns = "urn:xmpp:forward:0";
    13 local deplay_xmlns = "urn:xmpp:delay";
    13 local deplay_xmlns = "urn:xmpp:delay";
    14 
    14 
    15 
       
    16 module:log("debug", "**************************************")
       
    17 module:log("debug", "**************************************")
       
    18 module:log("debug", "**************************************")
       
    19 module:log("debug", "**************************************")
       
    20 module:log("debug", "**************************************")
       
    21 module:log("debug", "**************************************")
       
    22 module:log("debug", "**************************************")
       
    23 module:log("debug", "**************************************")
       
    24 module:log("debug", "**************************************")
       
    25 module:log("debug", "**************************************")
       
    26 module:log("debug", "**************************************")
       
    27 
    15 
    28 -- Returns a set of rooms the user is affiliated to
    16 -- Returns a set of rooms the user is affiliated to
    29 local function get_user_rooms(user_bare_jid)
    17 local function get_user_rooms(user_bare_jid)
    30 	return muc_affiliation_store:get_all(user_bare_jid);
    18 	return muc_affiliation_store:get_all(user_bare_jid);
    31 end
    19 end
    90 	end
    78 	end
    91 
    79 
    92 	return has_mentions, client_mentions
    80 	return has_mentions, client_mentions
    93 end
    81 end
    94 
    82 
    95 if rawget(_G, "setfenv") == nil then
       
    96 	rawset(_G, "setfenv", false)
       
    97 end
       
    98 if rawget(_G, "getfenv") == nil then
       
    99 	rawset(_G, "getfenv", false)
       
   100 end
       
   101 
       
   102 module:hook("muc-broadcast-message", function (event)
    83 module:hook("muc-broadcast-message", function (event)
   103 
       
   104 	require("mobdebug").start()
       
   105 	local room, stanza = event.room, event.stanza;
    84 	local room, stanza = event.room, event.stanza;
   106 	local body = stanza:get_child_text("body")
    85 	local body = stanza:get_child_text("body")
   107 	if not body or #body < 1 then return; end
    86 	if not body or #body < 1 then return; end
   108 	local correction = stanza:get_child("replace", "urn:xmpp:message-correct:0");
    87 	local correction = stanza:get_child("replace", "urn:xmpp:message-correct:0");
   109 	if correction then return; end -- Do not notify on message corrections
    88 	if correction then return; end -- Do not notify on message corrections