Merge 0.10->trunk
[prosody.git] / plugins / muc / history.lib.lua
index 1c14cf84ede12415518d7dc907c4016aaf66d416..d685abf2e11c0fcbad8c7cf6efcd7a8454e4c9f3 100644 (file)
@@ -130,12 +130,12 @@ local function send_history(room, stanza)
 end
 
 -- Send history on join
-module:hook("muc-occupant-joined", function(event)
+module:hook("muc-occupant-session-new", function(event)
        send_history(event.room, event.stanza);
 end, 50); -- Before subject(20)
 
 -- add to history
-module:hook("muc-broadcast-message", function(event)
+module:hook("muc-add-history", function(event)
        local historic = event.stanza:get_child("body");
        if historic then
                local room = event.room
@@ -151,6 +151,13 @@ module:hook("muc-broadcast-message", function(event)
                table.insert(history, entry);
                while #history > get_historylength(room) do table.remove(history, 1) end
        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);
 end);
 
 return {