Diff

plugins/mod_presence.lua @ 5069:7b298f8bcbcb

Merge Waqas<>Zash
author Matthew Wild <mwild1@gmail.com>
date Tue, 31 Jul 2012 23:07:02 +0100
parent 5060:b0e36777f715
child 5171:b4b302fe415c
line wrap: on
line diff
--- a/plugins/mod_presence.lua	Tue Jul 31 23:43:34 2012 +0200
+++ b/plugins/mod_presence.lua	Tue Jul 31 23:07:02 2012 +0100
@@ -198,12 +198,19 @@
 		core_post_stanza(origin, stanza);
 		send_presence_of_available_resources(node, host, to_bare, origin);
 	elseif stanza.attr.type == "unsubscribed" then
-		-- 1. route stanza
-		-- 2. roster push (subscription = none or to)
-		if rostermanager.unsubscribed(node, host, to_bare) then
-			rostermanager.roster_push(node, host, to_bare);
+		-- 1. send unavailable
+		-- 2. route stanza
+		-- 3. roster push (subscription = from or both)
+		local success, pending_in, subscribed = rostermanager.unsubscribed(node, host, to_bare);
+		if success then
+			if subscribed then
+				rostermanager.roster_push(node, host, to_bare);
+			end
+			core_post_stanza(origin, stanza);
+			if subscribed then
+				send_presence_of_available_resources(node, host, to_bare, origin, st.presence({ type = "unavailable" }));
+			end
 		end
-		core_post_stanza(origin, stanza);
 	else
 		origin.send(st.error_reply(stanza, "modify", "bad-request", "Invalid presence type"));
 	end