Mercurial > prosody-hg
comparison plugins/muc/mod_muc.lua @ 6334:ba2555e06c7c
plugins/muc/mod_muc: persistent rooms keyval store needs username as nil
| author | daurnimator <quae@daurnimator.com> |
|---|---|
| date | Thu, 07 Aug 2014 18:03:31 -0400 |
| parents | 93b8438fe761 |
| children | bffc885dc378 |
comparison
equal
deleted
inserted
replaced
| 6333:93b8438fe761 | 6334:ba2555e06c7c |
|---|---|
| 50 local room_configs = module:open_store("config"); | 50 local room_configs = module:open_store("config"); |
| 51 | 51 |
| 52 local function room_save(room, forced) | 52 local function room_save(room, forced) |
| 53 local node = jid_split(room.jid); | 53 local node = jid_split(room.jid); |
| 54 local is_persistent = persistent.get(room); | 54 local is_persistent = persistent.get(room); |
| 55 persistent_rooms:set(room.jid, is_persistent); | 55 persistent_rooms:set(nil, room.jid, is_persistent); |
| 56 if is_persistent then | 56 if is_persistent then |
| 57 local history = room._data.history; | 57 local history = room._data.history; |
| 58 room._data.history = nil; | 58 room._data.history = nil; |
| 59 local data = { | 59 local data = { |
| 60 jid = room.jid; | 60 jid = room.jid; |
| 100 function forget_room(jid) | 100 function forget_room(jid) |
| 101 rooms[jid] = nil; | 101 rooms[jid] = nil; |
| 102 local node = jid_split(room.jid); | 102 local node = jid_split(room.jid); |
| 103 room_configs:set(node, nil); | 103 room_configs:set(node, nil); |
| 104 if persistent.get(room_jid) then | 104 if persistent.get(room_jid) then |
| 105 persistent_rooms:set(room_jid, nil); | 105 persistent_rooms:set(nil, room_jid, nil); |
| 106 end | 106 end |
| 107 end | 107 end |
| 108 | 108 |
| 109 function get_room_from_jid(room_jid) | 109 function get_room_from_jid(room_jid) |
| 110 local room = rooms[room_jid]; | 110 local room = rooms[room_jid]; |
| 111 if room == nil then | 111 if room == nil then |
| 112 -- Check if in persistent storage | 112 -- Check if in persistent storage |
| 113 if persistent_rooms:get(room_jid) then | 113 if persistent_rooms:get(nil, room_jid) then |
| 114 room = restore_room(room_jid); | 114 room = restore_room(room_jid); |
| 115 if room == nil then | 115 if room == nil then |
| 116 module:log("error", "Missing data for room '%s', removing from persistent room list", room_jid); | 116 module:log("error", "Missing data for room '%s', removing from persistent room list", room_jid); |
| 117 persistent_rooms:set(room_jid, nil); | 117 persistent_rooms:set(nil, room_jid, nil); |
| 118 end | 118 end |
| 119 end | 119 end |
| 120 end | 120 end |
| 121 return room | 121 return room |
| 122 end | 122 end |
