Software /
code /
prosody
Comparison
core/rostermanager.lua @ 1897:6d81e74310a7
rostermanager: Added support for saving rosters of offline users to the save_roster function.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sun, 04 Oct 2009 21:25:59 +0500 |
parent | 1523:841d61be198f |
child | 1898:1ce02e2f5a3f |
comparison
equal
deleted
inserted
replaced
1866:cc7f212b2c48 | 1897:6d81e74310a7 |
---|---|
100 roster = 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); | 101 hosts[host].events.fire_event("roster-load", username, host, roster); |
102 return roster; | 102 return roster; |
103 end | 103 end |
104 | 104 |
105 function save_roster(username, host) | 105 function save_roster(username, host, roster) |
106 log("debug", "save_roster: saving roster for "..username.."@"..host); | 106 log("debug", "save_roster: saving roster for "..username.."@"..host); |
107 if hosts[host] and hosts[host].sessions[username] and hosts[host].sessions[username].roster then | 107 if not roster then |
108 roster = hosts[host] and hosts[host].sessions[username] and hosts[host].sessions[username].roster; | |
109 --if not roster then | |
110 -- --roster = load_roster(username, host); | |
111 -- return true; -- roster unchanged, no reason to save | |
112 --end | |
113 end | |
114 if roster then | |
108 local roster = hosts[host].sessions[username].roster; | 115 local roster = hosts[host].sessions[username].roster; |
109 roster[false].version = (roster[false].version or 1) + 1; | 116 roster[false].version = (roster[false].version or 1) + 1; |
110 return datamanager.store(username, host, "roster", hosts[host].sessions[username].roster); | 117 return datamanager.store(username, host, "roster", hosts[host].sessions[username].roster); |
111 end | 118 end |
112 log("warn", "save_roster: user had no roster to save"); | 119 log("warn", "save_roster: user had no roster to save"); |