Software /
code /
prosody-modules
Comparison
mod_mam/mamprefs.lib.lua @ 1111:bdbf76730f49
mod_mam: Split out preference functions into a lib for easy reuse
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 12 Jul 2013 22:46:15 +0200 |
child | 1136:a6d4508f7f28 |
comparison
equal
deleted
inserted
replaced
1110:97e238ce37ce | 1111:bdbf76730f49 |
---|---|
1 -- XEP-0313: Message Archive Management for Prosody | |
2 -- Copyright (C) 2011-2012 Kim Alvefur | |
3 -- | |
4 -- This file is MIT/X11 licensed. | |
5 | |
6 local host = module.host; | |
7 | |
8 local dm_load = require "util.datamanager".load; | |
9 local dm_store = require "util.datamanager".store; | |
10 | |
11 local global_default_policy = module:get_option("default_archive_policy", false); | |
12 | |
13 do | |
14 local prefs_format = { | |
15 [false] = "roster", | |
16 -- default ::= true | false | "roster" | |
17 -- true = always, false = never, nil = global default | |
18 ["romeo@montague.net"] = true, -- always | |
19 ["montague@montague.net"] = false, -- newer | |
20 }; | |
21 end | |
22 | |
23 local prefs_store = "archive2_prefs"; | |
24 local function get_prefs(user) | |
25 return dm_load(user, host, prefs_store) or | |
26 { [false] = global_default_policy }; | |
27 end | |
28 local function set_prefs(user, prefs) | |
29 return dm_store(user, host, prefs_store, prefs); | |
30 end | |
31 | |
32 return { | |
33 get = get_prefs, | |
34 set = set_prefs, | |
35 } |