aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2013-12-25 22:37:52 +0100
committerKim Alvefur <zash@zash.se>2013-12-25 22:37:52 +0100
commit2a25194b55d76eca92bafb30a3bb57cbf0b3bc1e (patch)
tree1dfec192a3daf96d14a26d33174e21d91547f858 /plugins
parentda4f11269dfc8f0157c94aa9c5f8e3eb2c5bc134 (diff)
downloadprosody-2a25194b55d76eca92bafb30a3bb57cbf0b3bc1e.tar.gz
prosody-2a25194b55d76eca92bafb30a3bb57cbf0b3bc1e.zip
mod_storage_sql2: Expose the unique key argument, allowing arbitrary ids. Conflicting items are removed.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_storage_sql2.lua8
1 files changed, 6 insertions, 2 deletions
diff --git a/plugins/mod_storage_sql2.lua b/plugins/mod_storage_sql2.lua
index bec35292..a97bee58 100644
--- a/plugins/mod_storage_sql2.lua
+++ b/plugins/mod_storage_sql2.lua
@@ -216,11 +216,15 @@ end
local archive_store = {}
archive_store.__index = archive_store
-function archive_store:append(username, when, with, value)
+function archive_store:append(username, key, when, with, value)
+ if value == nil then -- COMPAT early versions
+ when, with, value, key = key, when, with, value
+ end
local user,store = username,self.store;
return engine:transaction(function()
- local key = uuid.generate();
+ local key = key or uuid.generate();
local t, value = serialize(value);
+ engine:delete("DELETE FROM `prosodyarchive` WHERE `host`=? AND `user`=? AND `store`=? AND KEY=?", host, user or "", store, key);
engine:insert("INSERT INTO `prosodyarchive` (`host`, `user`, `store`, `when`, `with`, `key`, `type`, `value`) VALUES (?,?,?,?,?,?,?,?)", host, user or "", store, when, with, key, t, value);
return key;
end);