Mercurial > prosody-modules
comparison mod_mam/mamprefsxml.lib.lua @ 2014:dfa9c0cdd960
mod_mam: Remove application of defaults from preference xml encoding
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 19 Jan 2016 13:17:52 +0100 |
parents | 18349533c44d |
children | 5941aac79f06 |
comparison
equal
deleted
inserted
replaced
2013:a8ec8491fdee | 2014:dfa9c0cdd960 |
---|---|
3 -- | 3 -- |
4 -- This file is MIT/X11 licensed. | 4 -- This file is MIT/X11 licensed. |
5 | 5 |
6 local st = require"util.stanza"; | 6 local st = require"util.stanza"; |
7 local xmlns_mam = "urn:xmpp:mam:0"; | 7 local xmlns_mam = "urn:xmpp:mam:0"; |
8 | |
9 local global_default_policy = module:get_option("default_archive_policy", false); | |
10 | 8 |
11 local default_attrs = { | 9 local default_attrs = { |
12 always = true, [true] = "always", | 10 always = true, [true] = "always", |
13 never = false, [false] = "never", | 11 never = false, [false] = "never", |
14 roster = "roster", | 12 roster = "roster", |
15 } | 13 } |
16 | 14 |
17 local function tostanza(prefs) | 15 local function tostanza(prefs) |
18 local default = prefs[false]; | 16 local default = prefs[false]; |
19 default = default ~= nil and default_attrs[default] or global_default_policy; | 17 default = default_attrs[default]; |
20 local prefstanza = st.stanza("prefs", { xmlns = xmlns_mam, default = default }); | 18 local prefstanza = st.stanza("prefs", { xmlns = xmlns_mam, default = default }); |
21 local always = st.stanza("always"); | 19 local always = st.stanza("always"); |
22 local never = st.stanza("never"); | 20 local never = st.stanza("never"); |
23 for jid, choice in pairs(prefs) do | 21 for jid, choice in pairs(prefs) do |
24 if jid then | 22 if jid then |