Software /
code /
prosody
Comparison
plugins/mod_presence.lua @ 5776:bd0ff8ae98a8
Remove all trailing whitespace
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Fri, 09 Aug 2013 17:48:21 +0200 |
parent | 5416:0ba3a49d3863 |
child | 6281:8dc01fa767e0 |
comparison
equal
deleted
inserted
replaced
5775:a6c2b8933507 | 5776:bd0ff8ae98a8 |
---|---|
1 -- Prosody IM | 1 -- Prosody IM |
2 -- Copyright (C) 2008-2010 Matthew Wild | 2 -- Copyright (C) 2008-2010 Matthew Wild |
3 -- Copyright (C) 2008-2010 Waqas Hussain | 3 -- Copyright (C) 2008-2010 Waqas Hussain |
4 -- | 4 -- |
5 -- This project is MIT/X11 licensed. Please see the | 5 -- This project is MIT/X11 licensed. Please see the |
6 -- COPYING file in the source package for more information. | 6 -- COPYING file in the source package for more information. |
7 -- | 7 -- |
8 | 8 |
9 local log = module._log; | 9 local log = module._log; |
225 function handle_inbound_presence_subscriptions_and_probes(origin, stanza, from_bare, to_bare) | 225 function handle_inbound_presence_subscriptions_and_probes(origin, stanza, from_bare, to_bare) |
226 local node, host = jid_split(to_bare); | 226 local node, host = jid_split(to_bare); |
227 local st_from, st_to = stanza.attr.from, stanza.attr.to; | 227 local st_from, st_to = stanza.attr.from, stanza.attr.to; |
228 stanza.attr.from, stanza.attr.to = from_bare, to_bare; | 228 stanza.attr.from, stanza.attr.to = from_bare, to_bare; |
229 log("debug", "inbound presence %s from %s for %s", stanza.attr.type, from_bare, to_bare); | 229 log("debug", "inbound presence %s from %s for %s", stanza.attr.type, from_bare, to_bare); |
230 | 230 |
231 if stanza.attr.type == "probe" then | 231 if stanza.attr.type == "probe" then |
232 local result, err = rostermanager.is_contact_subscribed(node, host, from_bare); | 232 local result, err = rostermanager.is_contact_subscribed(node, host, from_bare); |
233 if result then | 233 if result then |
234 if 0 == send_presence_of_available_resources(node, host, st_from, origin) then | 234 if 0 == send_presence_of_available_resources(node, host, st_from, origin) then |
235 core_post_stanza(hosts[host], st.presence({from=to_bare, to=st_from, type="unavailable"}), true); -- TODO send last activity | 235 core_post_stanza(hosts[host], st.presence({from=to_bare, to=st_from, type="unavailable"}), true); -- TODO send last activity |
310 local t = stanza.attr.type; | 310 local t = stanza.attr.type; |
311 if to then | 311 if to then |
312 if t ~= nil and t ~= "unavailable" and t ~= "error" then -- check for subscriptions and probes sent to bare JID | 312 if t ~= nil and t ~= "unavailable" and t ~= "error" then -- check for subscriptions and probes sent to bare JID |
313 return handle_inbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to)); | 313 return handle_inbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to)); |
314 end | 314 end |
315 | 315 |
316 local user = bare_sessions[to]; | 316 local user = bare_sessions[to]; |
317 if user then | 317 if user then |
318 for _, session in pairs(user.sessions) do | 318 for _, session in pairs(user.sessions) do |
319 if session.presence then -- only send to available resources | 319 if session.presence then -- only send to available resources |
320 session.send(stanza); | 320 session.send(stanza); |
345 return true; | 345 return true; |
346 end); | 346 end); |
347 module:hook("presence/host", function(data) | 347 module:hook("presence/host", function(data) |
348 -- inbound presence to the host | 348 -- inbound presence to the host |
349 local stanza = data.stanza; | 349 local stanza = data.stanza; |
350 | 350 |
351 local from_bare = jid_bare(stanza.attr.from); | 351 local from_bare = jid_bare(stanza.attr.from); |
352 local t = stanza.attr.type; | 352 local t = stanza.attr.type; |
353 if t == "probe" then | 353 if t == "probe" then |
354 core_post_stanza(hosts[module.host], st.presence({ from = module.host, to = from_bare, id = stanza.attr.id })); | 354 core_post_stanza(hosts[module.host], st.presence({ from = module.host, to = from_bare, id = stanza.attr.id })); |
355 elseif t == "subscribe" then | 355 elseif t == "subscribe" then |