mod_mam/mamprefsxml.lib.lua
changeset 2018 dfa9c0cdd960
parent 1514 18349533c44d
child 2510 5941aac79f06
equal deleted inserted replaced
2017:a8ec8491fdee 2018: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