diff options
author | Kim Alvefur <zash@zash.se> | 2016-02-09 16:54:56 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2016-02-09 16:54:56 +0100 |
commit | 5320080656d2abacff6665d8ac1911d22ab2c170 (patch) | |
tree | e0db159c372ad6bbbf9fd7913f67104cca345d4c | |
parent | 5d689d9a6a0ea56f17d57ec213aff527c5965169 (diff) | |
download | prosody-5320080656d2abacff6665d8ac1911d22ab2c170.tar.gz prosody-5320080656d2abacff6665d8ac1911d22ab2c170.zip |
storagemanager: Add set_keys method to map store shim
-rw-r--r-- | core/storagemanager.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/core/storagemanager.lua b/core/storagemanager.lua index cf2c65d5..4f04e594 100644 --- a/core/storagemanager.lua +++ b/core/storagemanager.lua @@ -118,6 +118,23 @@ local map_shim_mt = { current[key] = data; return self.keyval_store:set(username, current); end; + set_keys = function (self, username, keydatas) + local current, err = self.keyval_store:get(username); + if current == nil then + if err then + return nil, err; + else + current = keydatas; + end + else + for k,v in pairs(keydatas) do + if v == self.remove then v = nil; end + current[k] = v; + end + end + return self.keyval_store:set(username, current); + end; + remove = {}; }; } |