Comparison

plugins/mod_presence.lua @ 5060:b0e36777f715

mod_presence, rostermanager: Bring outbound subscription cancellation in line with RFC6121.
author Waqas Hussain <waqas20@gmail.com>
date Wed, 01 Aug 2012 01:36:16 +0500
parent 5013:ab693eea0869
child 5171:b4b302fe415c
comparison
equal deleted inserted replaced
5059:246ba539a5cd 5060:b0e36777f715
196 rostermanager.roster_push(node, host, to_bare); 196 rostermanager.roster_push(node, host, to_bare);
197 end 197 end
198 core_post_stanza(origin, stanza); 198 core_post_stanza(origin, stanza);
199 send_presence_of_available_resources(node, host, to_bare, origin); 199 send_presence_of_available_resources(node, host, to_bare, origin);
200 elseif stanza.attr.type == "unsubscribed" then 200 elseif stanza.attr.type == "unsubscribed" then
201 -- 1. route stanza 201 -- 1. send unavailable
202 -- 2. roster push (subscription = none or to) 202 -- 2. route stanza
203 if rostermanager.unsubscribed(node, host, to_bare) then 203 -- 3. roster push (subscription = from or both)
204 rostermanager.roster_push(node, host, to_bare); 204 local success, pending_in, subscribed = rostermanager.unsubscribed(node, host, to_bare);
205 end 205 if success then
206 core_post_stanza(origin, stanza); 206 if subscribed then
207 rostermanager.roster_push(node, host, to_bare);
208 end
209 core_post_stanza(origin, stanza);
210 if subscribed then
211 send_presence_of_available_resources(node, host, to_bare, origin, st.presence({ type = "unavailable" }));
212 end
213 end
207 else 214 else
208 origin.send(st.error_reply(stanza, "modify", "bad-request", "Invalid presence type")); 215 origin.send(st.error_reply(stanza, "modify", "bad-request", "Invalid presence type"));
209 end 216 end
210 stanza.attr.from, stanza.attr.to = st_from, st_to; 217 stanza.attr.from, stanza.attr.to = st_from, st_to;
211 return true; 218 return true;