Software /
code /
prosody
Comparison
core/rostermanager.lua @ 7154:b3b92204802f
rostermanager: Use storagemanager
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 09 Feb 2016 17:01:04 +0100 |
parent | 7064:b98006bfd97a |
child | 7155:4a0825984e42 |
comparison
equal
deleted
inserted
replaced
7153:89fa66d4e502 | 7154:b3b92204802f |
---|---|
16 local type = type; | 16 local type = type; |
17 | 17 |
18 local hosts = hosts; | 18 local hosts = hosts; |
19 local bare_sessions = prosody.bare_sessions; | 19 local bare_sessions = prosody.bare_sessions; |
20 | 20 |
21 local datamanager = require "util.datamanager" | |
22 local um_user_exists = require "core.usermanager".user_exists; | 21 local um_user_exists = require "core.usermanager".user_exists; |
23 local st = require "util.stanza"; | 22 local st = require "util.stanza"; |
24 | 23 |
25 local _ENV = nil; | 24 local _ENV = nil; |
26 | 25 |
107 if roster then return roster; end | 106 if roster then return roster; end |
108 log("debug", "load_roster: loading for new user: %s@%s", username, host); | 107 log("debug", "load_roster: loading for new user: %s@%s", username, host); |
109 else -- Attempt to load roster for non-loaded user | 108 else -- Attempt to load roster for non-loaded user |
110 log("debug", "load_roster: loading for offline user: %s@%s", username, host); | 109 log("debug", "load_roster: loading for offline user: %s@%s", username, host); |
111 end | 110 end |
112 local data, err = datamanager.load(username, host, "roster"); | 111 local roster_store = require "core.storagemanager".open(host, "roster", "keyval"); |
112 local data, err = roster_store:get(username); | |
113 roster = data or {}; | 113 roster = data or {}; |
114 if user then user.roster = roster; end | 114 if user then user.roster = roster; end |
115 roster_metadata(roster, err); | 115 roster_metadata(roster, err); |
116 if roster[jid] then | 116 if roster[jid] then |
117 roster[jid] = nil; | 117 roster[jid] = nil; |
141 local metadata = roster_metadata(roster); | 141 local metadata = roster_metadata(roster); |
142 if metadata.version ~= true then | 142 if metadata.version ~= true then |
143 metadata.version = (metadata.version or 0) + 1; | 143 metadata.version = (metadata.version or 0) + 1; |
144 end | 144 end |
145 if metadata.broken then return nil, "Not saving broken roster" end | 145 if metadata.broken then return nil, "Not saving broken roster" end |
146 return datamanager.store(username, host, "roster", roster); | 146 local roster_store = require "core.storagemanager".open(host, "roster", "keyval"); |
147 return roster_store:set(username, roster); | |
147 end | 148 end |
148 log("warn", "save_roster: user had no roster to save"); | 149 log("warn", "save_roster: user had no roster to save"); |
149 return nil; | 150 return nil; |
150 end | 151 end |
151 | 152 |