Software /
code /
prosody
Annotate
plugins/mod_storage_memory.lua @ 10293:f9301d93de72 0.11
MUC: Strip tags with MUC-related namespaces from private messages (fixes #1427)
Prevents duplication since it adds another <{muc#user}x> here
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 29 Sep 2019 20:48:00 +0200 |
parent | 9881:68faa0c1a99c |
child | 9882:18f025b3987d |
rev | line source |
---|---|
9293
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 local serialize = require "util.serialization".serialize; |
9535
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
2 local array = require "util.array"; |
9293
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 local envload = require "util.envload".envload; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 local st = require "util.stanza"; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 local is_stanza = st.is_stanza or function (s) return getmetatable(s) == st.stanza_mt end |
9838
40ed04014b97
mod_storage_memory: Generate ID using standard util (fixes #1326)
Kim Alvefur <zash@zash.se>
parents:
9832
diff
changeset
|
6 local new_id = require "util.id".medium; |
9293
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 local auto_purge_enabled = module:get_option_boolean("storage_memory_temporary", false); |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 local auto_purge_stores = module:get_option_set("storage_memory_temporary_stores", {}); |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 local memory = setmetatable({}, { |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 __index = function(t, k) |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 local store = module:shared(k) |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 t[k] = store; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 return store; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 end |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 }); |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 local function NULL() return nil end |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 local function _purge_store(self, username) |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 self.store[username or NULL] = nil; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 return true; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 end |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 |
9881
68faa0c1a99c
mod_storage_memory: Implement :user iteration API
Kim Alvefur <zash@zash.se>
parents:
9838
diff
changeset
|
26 local function _users(self) |
68faa0c1a99c
mod_storage_memory: Implement :user iteration API
Kim Alvefur <zash@zash.se>
parents:
9838
diff
changeset
|
27 return next, self.store, nil; |
68faa0c1a99c
mod_storage_memory: Implement :user iteration API
Kim Alvefur <zash@zash.se>
parents:
9838
diff
changeset
|
28 end |
68faa0c1a99c
mod_storage_memory: Implement :user iteration API
Kim Alvefur <zash@zash.se>
parents:
9838
diff
changeset
|
29 |
9293
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 local keyval_store = {}; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
31 keyval_store.__index = keyval_store; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
33 function keyval_store:get(username) |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
34 return (self.store[username or NULL] or NULL)(); |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 end |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
37 function keyval_store:set(username, data) |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
38 if data ~= nil then |
9468
bd5e4485a245
mod_storage_memory: Switch from '@' prefix to '=' for chunks, '@' is used to indicate a source file name only
Matthew Wild <mwild1@gmail.com>
parents:
9340
diff
changeset
|
39 data = envload("return "..serialize(data), "=(data)", {}); |
9293
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
40 end |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
41 self.store[username or NULL] = data; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
42 return true; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
43 end |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
44 |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
45 keyval_store.purge = _purge_store; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
46 |
9881
68faa0c1a99c
mod_storage_memory: Implement :user iteration API
Kim Alvefur <zash@zash.se>
parents:
9838
diff
changeset
|
47 keyval_store.users = _users; |
68faa0c1a99c
mod_storage_memory: Implement :user iteration API
Kim Alvefur <zash@zash.se>
parents:
9838
diff
changeset
|
48 |
9293
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
49 local archive_store = {}; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
50 archive_store.__index = archive_store; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
51 |
9881
68faa0c1a99c
mod_storage_memory: Implement :user iteration API
Kim Alvefur <zash@zash.se>
parents:
9838
diff
changeset
|
52 archive_store.users = _users; |
68faa0c1a99c
mod_storage_memory: Implement :user iteration API
Kim Alvefur <zash@zash.se>
parents:
9838
diff
changeset
|
53 |
9293
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
54 function archive_store:append(username, key, value, when, with) |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
55 if is_stanza(value) then |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
56 value = st.preserialize(value); |
9468
bd5e4485a245
mod_storage_memory: Switch from '@' prefix to '=' for chunks, '@' is used to indicate a source file name only
Matthew Wild <mwild1@gmail.com>
parents:
9340
diff
changeset
|
57 value = envload("return xml"..serialize(value), "=(stanza)", { xml = st.deserialize }) |
9293
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
58 else |
9468
bd5e4485a245
mod_storage_memory: Switch from '@' prefix to '=' for chunks, '@' is used to indicate a source file name only
Matthew Wild <mwild1@gmail.com>
parents:
9340
diff
changeset
|
59 value = envload("return "..serialize(value), "=(data)", {}); |
9293
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
60 end |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
61 local a = self.store[username or NULL]; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
62 if not a then |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
63 a = {}; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
64 self.store[username or NULL] = a; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
65 end |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
66 local v = { key = key, when = when, with = with, value = value }; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
67 if not key then |
9838
40ed04014b97
mod_storage_memory: Generate ID using standard util (fixes #1326)
Kim Alvefur <zash@zash.se>
parents:
9832
diff
changeset
|
68 key = new_id(); |
9293
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
69 v.key = key; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
70 end |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
71 if a[key] then |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
72 table.remove(a, a[key]); |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
73 end |
9534
b301f7edf346
mod_storage_memory: Fix overwriting old keys
Kim Alvefur <zash@zash.se>
parents:
9533
diff
changeset
|
74 local i = #a+1; |
9293
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
75 a[i] = v; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
76 a[key] = i; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
77 return key; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
78 end |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
79 |
9832
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
80 function archive_store:find(username, query) |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
81 local items = self.store[username or NULL]; |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
82 if not items then |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
83 return function () end, 0; |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
84 end |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
85 local count = #items; |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
86 local i = 0; |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
87 if query then |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
88 items = array():append(items); |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
89 if query.key then |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
90 items:filter(function (item) |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
91 return item.key == query.key; |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
92 end); |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
93 end |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
94 if query.with then |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
95 items:filter(function (item) |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
96 return item.with == query.with; |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
97 end); |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
98 end |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
99 if query.start then |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
100 items:filter(function (item) |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
101 return item.when >= query.start; |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
102 end); |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
103 end |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
104 if query["end"] then |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
105 items:filter(function (item) |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
106 return item.when <= query["end"]; |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
107 end); |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
108 end |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
109 count = #items; |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
110 if query.reverse then |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
111 items:reverse(); |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
112 if query.before then |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
113 for j = 1, count do |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
114 if (items[j].key or tostring(j)) == query.before then |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
115 i = j; |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
116 break; |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
117 end |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
118 end |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
119 end |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
120 elseif query.after then |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
121 for j = 1, count do |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
122 if (items[j].key or tostring(j)) == query.after then |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
123 i = j; |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
124 break; |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
125 end |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
126 end |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
127 end |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
128 if query.limit and #items - i > query.limit then |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
129 items[i+query.limit+1] = nil; |
9293
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
130 end |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
131 end |
9832
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
132 return function () |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
133 i = i + 1; |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
134 local item = items[i]; |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
135 if not item then return; end |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
136 return item.key, item.value(), item.when, item.with; |
96d9c121547b
mod_storage_memory: Replace query function with one based on storage_internal (fixes #1322)
Kim Alvefur <zash@zash.se>
parents:
9609
diff
changeset
|
137 end, count; |
9293
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
138 end |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
139 |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
140 |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
141 function archive_store:delete(username, query) |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
142 if not query or next(query) == nil then |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
143 self.store[username or NULL] = nil; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
144 return true; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
145 end |
9535
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
146 local items = self.store[username or NULL]; |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
147 if not items then |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
148 -- Store is empty |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
149 return 0; |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
150 end |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
151 items = array(items); |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
152 local count_before = #items; |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
153 if query then |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
154 if query.key then |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
155 items:filter(function (item) |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
156 return item.key ~= query.key; |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
157 end); |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
158 end |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
159 if query.with then |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
160 items:filter(function (item) |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
161 return item.with ~= query.with; |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
162 end); |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
163 end |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
164 if query.start then |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
165 items:filter(function (item) |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
166 return item.when < query.start; |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
167 end); |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
168 end |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
169 if query["end"] then |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
170 items:filter(function (item) |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
171 return item.when > query["end"]; |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
172 end); |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
173 end |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
174 if query.truncate and #items > query.truncate then |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
175 if query.reverse then |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
176 -- Before: { 1, 2, 3, 4, 5, } |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
177 -- After: { 1, 2, 3 } |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
178 for i = #items, query.truncate + 1, -1 do |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
179 items[i] = nil; |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
180 end |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
181 else |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
182 -- Before: { 1, 2, 3, 4, 5, } |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
183 -- After: { 3, 4, 5 } |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
184 local offset = #items - query.truncate; |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
185 for i = 1, #items do |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
186 items[i] = items[i+offset]; |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
187 end |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
188 end |
9293
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
189 end |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
190 end |
9535
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
191 local count = count_before - #items; |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
192 if count == 0 then |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
193 return 0; -- No changes, skip write |
9293
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
194 end |
9535
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
195 setmetatable(items, nil); |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
196 |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
197 do -- re-index by key |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
198 for k in pairs(items) do |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
199 if type(k) == "string" then |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
200 items[k] = nil; |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
201 end |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
202 end |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
203 |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
204 for i = 1, #items do |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
205 items[ items[i].key ] = i; |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
206 end |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
207 end |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
208 |
c1befd1c886d
mod_storage_memory: Adapt archive deletion code from mod_storage_internal
Kim Alvefur <zash@zash.se>
parents:
9534
diff
changeset
|
209 return count; |
9293
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
210 end |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
211 |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
212 archive_store.purge = _purge_store; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
213 |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
214 local stores = { |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
215 keyval = keyval_store; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
216 archive = archive_store; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
217 } |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
218 |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
219 local driver = {}; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
220 |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
221 function driver:open(store, typ) -- luacheck: ignore 212/self |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
222 local store_mt = stores[typ or "keyval"]; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
223 if store_mt then |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
224 return setmetatable({ store = memory[store] }, store_mt); |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
225 end |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
226 return nil, "unsupported-store"; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
227 end |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
228 |
9609
1dfcea523200
mod_storage_memory: Support the purge driver method
Kim Alvefur <zash@zash.se>
parents:
9535
diff
changeset
|
229 function driver:purge(user) -- luacheck: ignore 212/self |
1dfcea523200
mod_storage_memory: Support the purge driver method
Kim Alvefur <zash@zash.se>
parents:
9535
diff
changeset
|
230 for _, store in pairs(memory) do |
1dfcea523200
mod_storage_memory: Support the purge driver method
Kim Alvefur <zash@zash.se>
parents:
9535
diff
changeset
|
231 store[user] = nil; |
1dfcea523200
mod_storage_memory: Support the purge driver method
Kim Alvefur <zash@zash.se>
parents:
9535
diff
changeset
|
232 end |
1dfcea523200
mod_storage_memory: Support the purge driver method
Kim Alvefur <zash@zash.se>
parents:
9535
diff
changeset
|
233 end |
1dfcea523200
mod_storage_memory: Support the purge driver method
Kim Alvefur <zash@zash.se>
parents:
9535
diff
changeset
|
234 |
9293
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
235 if auto_purge_enabled then |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
236 module:hook("resource-unbind", function (event) |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
237 local user_bare_jid = event.session.username.."@"..event.session.host; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
238 if not prosody.bare_sessions[user_bare_jid] then -- User went offline |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
239 module:log("debug", "Clearing store for offline user %s", user_bare_jid); |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
240 local f, s, v; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
241 if auto_purge_stores:empty() then |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
242 f, s, v = pairs(memory); |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
243 else |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
244 f, s, v = auto_purge_stores:items(); |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
245 end |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
246 |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
247 for store_name in f, s, v do |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
248 if memory[store_name] then |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
249 memory[store_name][event.session.username] = nil; |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
250 end |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
251 end |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
252 end |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
253 end); |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
254 end |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
255 |
0a751835627d
mod_storage_memory: Import from prosody-modules 4c3230c22c18
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
256 module:provides("storage", driver); |