226 local st_from, st_to = stanza.attr.from, stanza.attr.to; |
226 local st_from, st_to = stanza.attr.from, stanza.attr.to; |
227 stanza.attr.from, stanza.attr.to = from_bare, to_bare; |
227 stanza.attr.from, stanza.attr.to = from_bare, to_bare; |
228 log("debug", "inbound presence "..stanza.attr.type.." from "..from_bare.." for "..to_bare); |
228 log("debug", "inbound presence "..stanza.attr.type.." from "..from_bare.." for "..to_bare); |
229 |
229 |
230 if stanza.attr.type == "probe" then |
230 if stanza.attr.type == "probe" then |
231 if rostermanager.is_contact_subscribed(node, host, from_bare) then |
231 local result, err = rostermanager.is_contact_subscribed(node, host, from_bare); |
|
232 if result then |
232 if 0 == send_presence_of_available_resources(node, host, st_from, origin, core_route_stanza) then |
233 if 0 == send_presence_of_available_resources(node, host, st_from, origin, core_route_stanza) then |
233 core_route_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="unavailable"})); -- TODO send last activity |
234 core_route_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="unavailable"})); -- TODO send last activity |
234 end |
235 end |
235 else |
236 elseif not err then |
236 core_route_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="unsubscribed"})); |
237 core_route_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="unsubscribed"})); |
237 end |
238 end |
238 elseif stanza.attr.type == "subscribe" then |
239 elseif stanza.attr.type == "subscribe" then |
239 if rostermanager.is_contact_subscribed(node, host, from_bare) then |
240 if rostermanager.is_contact_subscribed(node, host, from_bare) then |
240 core_route_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="subscribed"})); -- already subscribed |
241 core_route_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="subscribed"})); -- already subscribed |