Delete the offline message store only when offline messages are present

Fri, 26 Dec 2008 21:48:08 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Fri, 26 Dec 2008 21:48:08 +0500
changeset 649
5f8382768530
parent 648
3f34b83771eb
child 650
674531bcb5c4

Delete the offline message store only when offline messages are present

core/presencemanager.lua file | annotate | diff | comparison | revisions
--- a/core/presencemanager.lua	Fri Dec 26 21:46:05 2008 +0500
+++ b/core/presencemanager.lua	Fri Dec 26 21:48:08 2008 +0500
@@ -95,11 +95,14 @@
 					request.attr.to = jid;
 					core_route_stanza(origin, request);
 				end
+			end
+			local offline = offlinemanager.load(node, host);
+			if offline then
+				for _, msg in ipairs(offline) do
+					origin.send(msg); -- FIXME do we need to modify to/from in any way?
+				end
+				offlinemanager.deleteAll(node, host);
 			end
-			for _, msg in ipairs(offlinemanager.load(node, host) or {}) do
-				origin.send(msg); -- FIXME do we need to modify to/from in any way?
-			end
-			offlinemanager.deleteAll(node, host);
 		end
 		origin.priority = 0;
 		if stanza.attr.type == "unavailable" then

mercurial