plugins/mod_presence.lua

changeset 3112
c311fdffccce
parent 3109
34280b1544fc
child 3166
190827ba4591
child 3185
a31559c52842
equal deleted inserted replaced
3111:826cb5f1859b 3112:c311fdffccce
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

mercurial