comparison mod_mam/mod_mam.lua @ 675:da33325453fb

mod_mam: Put name of store in a single variable
author Kim Alvefur <zash@zash.se>
date Thu, 24 May 2012 23:52:36 +0200
parents 699187d18f11
children cc5805f83583
comparison
equal deleted inserted replaced
674:699187d18f11 675:da33325453fb
40 ["romeo@montague.net"] = true, -- always 40 ["romeo@montague.net"] = true, -- always
41 ["montague@montague.net"] = false, -- newer 41 ["montague@montague.net"] = false, -- newer
42 }; 42 };
43 end 43 end
44 44
45 local prefs_store = "archive2_prefs"; 45 local archive_store = "archive2";
46 local prefs_store = archive_store .. "_prefs";
46 local function get_prefs(user) 47 local function get_prefs(user)
47 return dm_load(user, host, prefs_store) or 48 return dm_load(user, host, prefs_store) or
48 { [false] = global_default_policy }; 49 { [false] = global_default_policy };
49 end 50 end
50 local function set_prefs(user, prefs) 51 local function set_prefs(user, prefs)
122 tostring(qid), qwith or "anyone", qstart or "the dawn of time", qend or "now"); 123 tostring(qid), qwith or "anyone", qstart or "the dawn of time", qend or "now");
123 124
124 qstart, qend = (qstart and timestamp_parse(qstart)), (qend and timestamp_parse(qend)) 125 qstart, qend = (qstart and timestamp_parse(qstart)), (qend and timestamp_parse(qend))
125 126
126 -- Load all the data! 127 -- Load all the data!
127 local data, err = dm_list_load(origin.username, origin.host, "archive2"); 128 local data, err = dm_list_load(origin.username, origin.host, archive_store);
128 if not data then 129 if not data then
129 if (not err) then 130 if (not err) then
130 module:log("debug", "The archive was empty."); 131 module:log("debug", "The archive was empty.");
131 origin.send(st.reply(stanza)); 132 origin.send(st.reply(stanza));
132 else 133 else
226 module:log("debug", "Archiving stanza: %s", stanza:top_tag()); 227 module:log("debug", "Archiving stanza: %s", stanza:top_tag());
227 228
228 local id = uuid(); 229 local id = uuid();
229 local when = time_now(); 230 local when = time_now();
230 -- And stash it 231 -- And stash it
231 local ok, err = dm_list_append(store_user, store_host, "archive2", { 232 local ok, err = dm_list_append(store_user, store_host, archive_store, {
232 -- WARNING This format may change. 233 -- WARNING This format may change.
233 id = id, 234 id = id,
234 when = when, -- This might be an UNIX timestamp. Probably. 235 when = when, -- This might be an UNIX timestamp. Probably.
235 timestamp = timestamp(when), -- Textual timestamp. But I'll assume that comparing numbers is faster and less annoying in case of timezones. 236 timestamp = timestamp(when), -- Textual timestamp. But I'll assume that comparing numbers is faster and less annoying in case of timezones.
236 with = target_jid, 237 with = target_jid,