prosodyctl: Add message describing the distinguished name input expected
[prosody.git] / plugins / mod_offline.lua
index edd141902de86b3c1ea684d839201f3a784e071b..1ac62f94737a70ad17ab5401ab01a63c2776d5f9 100644 (file)
@@ -15,7 +15,7 @@ local jid_split = require "util.jid".split;
 
 module:add_feature("msgoffline");
 
-module:hook("message/offline/store", function(event)
+module:hook("message/offline/handle", function(event)
        local origin, stanza = event.origin, event.stanza;
        local to = stanza.attr.to;
        local node, host;
@@ -29,31 +29,23 @@ module:hook("message/offline/store", function(event)
        local result = datamanager.list_append(node, host, "offline", st.preserialize(stanza));
        stanza.attr.stamp, stanza.attr.stamp_legacy = nil, nil;
        
-       return true;
+       return result;
 end);
 
 module:hook("message/offline/broadcast", function(event)
        local origin = event.origin;
 
-        if origin.priority >= 0 then
-          local node, host = origin.username, origin.host;
-          
-          local data = datamanager.list_load(node, host, "offline");
-          if not data then return true; end
-          for _, stanza in ipairs(data) do
-                  stanza = st.deserialize(stanza);
-                  stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = host, stamp = stanza.attr.stamp}):up(); -- XEP-0203
-                  stanza:tag("x", {xmlns = "jabber:x:delay", from = host, stamp = stanza.attr.stamp_legacy}):up(); -- XEP-0091 (deprecated)
-                  stanza.attr.stamp, stanza.attr.stamp_legacy = nil, nil;
-                  origin.send(stanza);
-          end
-          return true;
-        end
-end);
-
-module:hook("message/offline/delete", function(event)
-       local origin = event.origin;
        local node, host = origin.username, origin.host;
 
-       return datamanager.list_store(node, host, "offline", nil);
+       local data = datamanager.list_load(node, host, "offline");
+       if not data then return true; end
+       for _, stanza in ipairs(data) do
+               stanza = st.deserialize(stanza);
+               stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = host, stamp = stanza.attr.stamp}):up(); -- XEP-0203
+               stanza:tag("x", {xmlns = "jabber:x:delay", from = host, stamp = stanza.attr.stamp_legacy}):up(); -- XEP-0091 (deprecated)
+               stanza.attr.stamp, stanza.attr.stamp_legacy = nil, nil;
+               origin.send(stanza);
+       end
+       datamanager.list_store(node, host, "offline", nil);
+       return true;
 end);