Comparison

mod_carbons/mod_carbons.lua @ 585:ce2798a1bc56

mod_carbons: Don't try to send carbons for entirely offline users.
author Kim Alvefur <zash@zash.se>
date Sat, 28 Jan 2012 15:10:04 +0100
parent 545:77f350635f4f
child 605:5175f6d33470
comparison
equal deleted inserted replaced
584:1c2fc3b845f2 585:ce2798a1bc56
52 local username, hostname, resource = jid_split(orig_to); 52 local username, hostname, resource = jid_split(orig_to);
53 bare_jid = jid_bare(orig_to); 53 bare_jid = jid_bare(orig_to);
54 user_sessions = host_sessions[username]; 54 user_sessions = host_sessions[username];
55 if resource then 55 if resource then
56 no_carbon_to[resource] = true; 56 no_carbon_to[resource] = true;
57 else 57 elseif user_sessions then
58 local top_resources = user_sessions.top_resources; 58 local top_resources = user_sessions.top_resources;
59 for _, session in ipairs(top_resources) do 59 if top_resources then
60 no_carbon_to[session.resource] = true; 60 for _, session in ipairs(top_resources) do
61 no_carbon_to[session.resource] = true;
62 end
61 end 63 end
62 end 64 end
65 end
66
67 if not user_sessions then
68 return -- No use in sending carbons to an offline user
63 end 69 end
64 70
65 if not c2s and stanza:get_child("private", xmlns_carbons) then 71 if not c2s and stanza:get_child("private", xmlns_carbons) then
66 stanza:maptags(function(tag) 72 stanza:maptags(function(tag)
67 return tag.attr.xmlns == xmlns_carbons 73 return tag.attr.xmlns == xmlns_carbons