plugins/mod_mam/mamprefsxml.lib.lua
branch0.11
changeset 9732 d41ce505cdf9
parent 7906 036c771b842a
child 12981 74b9e05af71e
equal deleted inserted replaced
9722:81ef96368bff 9732:d41ce505cdf9
     1 -- Prosody IM
     1 -- Prosody IM
     2 -- Copyright (C) 2008-2017 Matthew Wild
     2 -- Copyright (C) 2008-2017 Matthew Wild
     3 -- Copyright (C) 2008-2017 Waqas Hussain
     3 -- Copyright (C) 2008-2017 Waqas Hussain
     4 -- Copyright (C) 2011-2017 Kim Alvefur
     4 -- Copyright (C) 2011-2017 Kim Alvefur
       
     5 -- Copyright (C) 2018 Emmanuel Gil Peyrot
     5 --
     6 --
     6 -- This project is MIT/X11 licensed. Please see the
     7 -- This project is MIT/X11 licensed. Please see the
     7 -- COPYING file in the source package for more information.
     8 -- COPYING file in the source package for more information.
     8 --
     9 --
     9 -- XEP-0313: Message Archive Management for Prosody
    10 -- XEP-0313: Message Archive Management for Prosody
    10 --
    11 --
    11 
    12 
    12 local st = require"util.stanza";
    13 local st = require"util.stanza";
       
    14 local jid_prep = require"util.jid".prep;
    13 local xmlns_mam = "urn:xmpp:mam:2";
    15 local xmlns_mam = "urn:xmpp:mam:2";
    14 
    16 
    15 local default_attrs = {
    17 local default_attrs = {
    16 	always = true, [true] = "always",
    18 	always = true, [true] = "always",
    17 	never = false, [false] = "never",
    19 	never = false, [false] = "never",
    40 	end
    42 	end
    41 
    43 
    42 	local always = prefstanza:get_child("always");
    44 	local always = prefstanza:get_child("always");
    43 	if always then
    45 	if always then
    44 		for rule in always:childtags("jid") do
    46 		for rule in always:childtags("jid") do
    45 			local jid = rule:get_text();
    47 			local jid = jid_prep(rule:get_text());
    46 			prefs[jid] = true;
    48 			if jid then
       
    49 				prefs[jid] = true;
       
    50 			end
    47 		end
    51 		end
    48 	end
    52 	end
    49 
    53 
    50 	local never = prefstanza:get_child("never");
    54 	local never = prefstanza:get_child("never");
    51 	if never then
    55 	if never then
    52 		for rule in never:childtags("jid") do
    56 		for rule in never:childtags("jid") do
    53 			local jid = rule:get_text();
    57 			local jid = jid_prep(rule:get_text());
    54 			prefs[jid] = false;
    58 			if jid then
       
    59 				prefs[jid] = false;
       
    60 			end
    55 		end
    61 		end
    56 	end
    62 	end
    57 
    63 
    58 	return prefs;
    64 	return prefs;
    59 end
    65 end