From e494fc201fa003eedcacdb8f172177247216b1cb Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 18 Jan 2014 20:14:05 +0100 Subject: MUC: Fire muc-room-destroyed event when the last participant leaves a non-persistent room --- plugins/muc/mod_muc.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins') diff --git a/plugins/muc/mod_muc.lua b/plugins/muc/mod_muc.lua index edebf070..6e86ab73 100644 --- a/plugins/muc/mod_muc.lua +++ b/plugins/muc/mod_muc.lua @@ -163,6 +163,7 @@ function stanza_handler(event) if room then room:handle_stanza(origin, stanza); if not next(room._occupants) and not persistent_rooms[room.jid] then -- empty, non-persistent room + module:fire_event("muc-room-destroyed", { room = room }); rooms[bare] = nil; -- discard room end else -- cgit v1.2.3 From 372c2b460a00506bd779c8081dc3774b6e81d93b Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 21 Jan 2014 00:51:31 +0100 Subject: mod_storage_sql2: Fix another SQL syntax error that slipped trough --- plugins/mod_storage_sql2.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_storage_sql2.lua b/plugins/mod_storage_sql2.lua index b9e9d3ca..e02ad681 100644 --- a/plugins/mod_storage_sql2.lua +++ b/plugins/mod_storage_sql2.lua @@ -224,7 +224,7 @@ function archive_store:append(username, key, when, with, value) return engine:transaction(function() 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: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); -- cgit v1.2.3 From 9550295c9d54f962435836dffc708bba67feaad5 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 21 Jan 2014 01:51:13 +0100 Subject: mod_storage_sql2: Only attempt to delete conflicting items if an ID/key is given --- plugins/mod_storage_sql2.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_storage_sql2.lua b/plugins/mod_storage_sql2.lua index e02ad681..90e9ead0 100644 --- a/plugins/mod_storage_sql2.lua +++ b/plugins/mod_storage_sql2.lua @@ -222,9 +222,12 @@ function archive_store:append(username, key, when, with, value) end local user,store = username,self.store; return engine:transaction(function() - local key = key or uuid.generate(); + if key then + engine:delete("DELETE FROM `prosodyarchive` WHERE `host`=? AND `user`=? AND `store`=? AND `key`=?", host, user or "", store, key); + else + key = uuid.generate(); + end 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); -- cgit v1.2.3