Software /
code /
prosody
Comparison
core/rostermanager.lua @ 4993:5243b74a4cbb
Hopefully inert commit to clean up logging across a number of modules, removing all cases of concatenation when building log messages
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 23 Jul 2012 17:32:33 +0100 |
parent | 3129:125f03db0b1a |
child | 5024:d25e1b9332cc |
comparison
equal
deleted
inserted
replaced
4992:e79e4d1f75de | 4993:5243b74a4cbb |
---|---|
81 end | 81 end |
82 end | 82 end |
83 | 83 |
84 function load_roster(username, host) | 84 function load_roster(username, host) |
85 local jid = username.."@"..host; | 85 local jid = username.."@"..host; |
86 log("debug", "load_roster: asked for: "..jid); | 86 log("debug", "load_roster: asked for: %s", jid); |
87 local user = bare_sessions[jid]; | 87 local user = bare_sessions[jid]; |
88 local roster; | 88 local roster; |
89 if user then | 89 if user then |
90 roster = user.roster; | 90 roster = user.roster; |
91 if roster then return roster; end | 91 if roster then return roster; end |
92 log("debug", "load_roster: loading for new user: "..username.."@"..host); | 92 log("debug", "load_roster: loading for new user: %s@%s", username, host); |
93 else -- Attempt to load roster for non-loaded user | 93 else -- Attempt to load roster for non-loaded user |
94 log("debug", "load_roster: loading for offline user: "..username.."@"..host); | 94 log("debug", "load_roster: loading for offline user: %s@%s", username, host); |
95 end | 95 end |
96 local data, err = datamanager.load(username, host, "roster"); | 96 local data, err = datamanager.load(username, host, "roster"); |
97 roster = data or {}; | 97 roster = data or {}; |
98 if user then user.roster = roster; end | 98 if user then user.roster = roster; end |
99 if not roster[false] then roster[false] = { broken = err or nil }; end | 99 if not roster[false] then roster[false] = { broken = err or nil }; end |
100 if roster[jid] then | 100 if roster[jid] then |
101 roster[jid] = nil; | 101 roster[jid] = nil; |
102 log("warn", "roster for "..jid.." has a self-contact"); | 102 log("warn", "roster for %s has a self-contact", jid); |
103 end | 103 end |
104 if not err then | 104 if not err then |
105 hosts[host].events.fire_event("roster-load", username, host, roster); | 105 hosts[host].events.fire_event("roster-load", username, host, roster); |
106 end | 106 end |
107 return roster, err; | 107 return roster, err; |
108 end | 108 end |
109 | 109 |
110 function save_roster(username, host, roster) | 110 function save_roster(username, host, roster) |
111 log("debug", "save_roster: saving roster for "..username.."@"..host); | 111 log("debug", "save_roster: saving roster for %s@%s", username, host); |
112 if not roster then | 112 if not roster then |
113 roster = hosts[host] and hosts[host].sessions[username] and hosts[host].sessions[username].roster; | 113 roster = hosts[host] and hosts[host].sessions[username] and hosts[host].sessions[username].roster; |
114 --if not roster then | 114 --if not roster then |
115 -- --roster = load_roster(username, host); | 115 -- --roster = load_roster(username, host); |
116 -- return true; -- roster unchanged, no reason to save | 116 -- return true; -- roster unchanged, no reason to save |
236 if not item then | 236 if not item then |
237 item = {subscription = "none", groups = {}}; | 237 item = {subscription = "none", groups = {}}; |
238 roster[jid] = item; | 238 roster[jid] = item; |
239 end | 239 end |
240 item.ask = "subscribe"; | 240 item.ask = "subscribe"; |
241 log("debug", "set_contact_pending_out: saving roster; set "..username.."@"..host..".roster["..jid.."].ask=subscribe"); | 241 log("debug", "set_contact_pending_out: saving roster; set %s@%s.roster[%q].ask=subscribe", username, host, jid); |
242 return save_roster(username, host, roster); | 242 return save_roster(username, host, roster); |
243 end | 243 end |
244 function unsubscribe(username, host, jid) | 244 function unsubscribe(username, host, jid) |
245 local roster = load_roster(username, host); | 245 local roster = load_roster(username, host); |
246 local item = roster[jid]; | 246 local item = roster[jid]; |