Software /
code /
prosody
Comparison
core/rostermanager.lua @ 1380:9b3b43b8963a
rostermanager: Fire event on roster load
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 22 Jun 2009 14:14:28 +0100 |
parent | 925:4861bcf0afa4 |
child | 1523:841d61be198f |
comparison
equal
deleted
inserted
replaced
1379:03d8a930053f | 1380:9b3b43b8963a |
---|---|
80 end | 80 end |
81 end | 81 end |
82 | 82 |
83 function load_roster(username, host) | 83 function load_roster(username, host) |
84 log("debug", "load_roster: asked for: "..username.."@"..host); | 84 log("debug", "load_roster: asked for: "..username.."@"..host); |
85 local roster; | |
85 if hosts[host] and hosts[host].sessions[username] then | 86 if hosts[host] and hosts[host].sessions[username] then |
86 local roster = hosts[host].sessions[username].roster; | 87 roster = hosts[host].sessions[username].roster; |
87 if not roster then | 88 if not roster then |
88 log("debug", "load_roster: loading for new user: "..username.."@"..host); | 89 log("debug", "load_roster: loading for new user: "..username.."@"..host); |
89 roster = datamanager.load(username, host, "roster") or {}; | 90 roster = datamanager.load(username, host, "roster") or {}; |
90 if not roster[false] then roster[false] = { }; end | 91 if not roster[false] then roster[false] = { }; end |
91 hosts[host].sessions[username].roster = roster; | 92 hosts[host].sessions[username].roster = roster; |
93 hosts[host].events.fire_event("roster-load", username, host, roster); | |
92 end | 94 end |
93 return roster; | 95 return roster; |
94 end | 96 end |
97 | |
95 -- Attempt to load roster for non-loaded user | 98 -- Attempt to load roster for non-loaded user |
96 log("debug", "load_roster: loading for offline user: "..username.."@"..host); | 99 log("debug", "load_roster: loading for offline user: "..username.."@"..host); |
97 return datamanager.load(username, host, "roster") or {}; | 100 roster = datamanager.load(username, host, "roster") or {}; |
101 hosts[host].events.fire_event("roster-load", username, host, roster); | |
102 return roster; | |
98 end | 103 end |
99 | 104 |
100 function save_roster(username, host) | 105 function save_roster(username, host) |
101 log("debug", "save_roster: saving roster for "..username.."@"..host); | 106 log("debug", "save_roster: saving roster for "..username.."@"..host); |
102 if hosts[host] and hosts[host].sessions[username] and hosts[host].sessions[username].roster then | 107 if hosts[host] and hosts[host].sessions[username] and hosts[host].sessions[username].roster then |