Directed presence
[prosody.git] / core / presencemanager.lua
index 6e27752b0dedb5405cbcede49523f8d12a97f428..4d8475631871d60edf57cdc890284bf1e586dd0c 100644 (file)
@@ -1,4 +1,4 @@
--- Prosody IM v0.1
+-- Prosody IM v0.2
 -- Copyright (C) 2008 Matthew Wild
 -- Copyright (C) 2008 Waqas Hussain
 -- 
@@ -103,7 +103,14 @@ function handle_normal_presence(origin, stanza, core_route_stanza)
                end\r
                origin.priority = 0;\r
                if stanza.attr.type == "unavailable" then\r
-                       origin.presence = nil;\r
+                       origin.presence = nil;
+                       if origin.directed then
+                               for _, jid in ipairs(origin.directed) do
+                                       stanza.attr.to = jid;
+                                       core_route_stanza(origin, stanza);
+                               end
+                               origin.directed = nil;
+                       end\r
                else\r
                        origin.presence = stanza;\r
                        local priority = stanza:child_with_name("priority");\r