changeset 174:d40982d130f0

mod_blocking: Various small changes to make it actually work, which I forgot to commit
author Matthew Wild <mwild1@gmail.com>
date Sun, 13 Jun 2010 19:51:15 +0100
parents 4f58ddade1db
children 92a72435721a
files mod_blocking/mod_blocking.lua
diffstat 1 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mod_blocking/mod_blocking.lua	Sun Jun 13 22:45:26 2010 +0500
+++ b/mod_blocking/mod_blocking.lua	Sun Jun 13 19:51:15 2010 +0100
@@ -1,3 +1,8 @@
+local jid_split = require "util.jid".split;
+local st = require "util.stanza";
+
+local xmlns_blocking = "urn:xmpp:blocking";
+
 module:add_feature("urn:xmpp:blocking");
 
 -- Add JID to default privacy list
@@ -8,13 +13,13 @@
 		default_list_name = "blocklist";
 		privacy_lists.default = default_list_name;
 	end
-	local default_list = privacy_lists.list[default_list_name];
+	local default_list = privacy_lists.lists[default_list_name];
 	if not default_list then
 		default_list = { name = default_list_name, items = {} };
 		privacy_lists.lists[default_list_name] = default_list;
 	end
 	local items = default_list.items;
-	local order = items[1].order; -- Must come first
+	local order = items[1] and items[1].order or 0; -- Must come first
 	for i=1,#items do -- order must be unique
 		items[i].order = items[i].order + 1;
 	end
@@ -35,7 +40,7 @@
 	local privacy_lists = datamanager.load(username, host, "privacy") or {};
 	local default_list_name = privacy_lists.default;
 	if not default_list_name then return; end
-	local default_list = privacy_lists.list[default_list_name];
+	local default_list = privacy_lists.lists[default_list_name];
 	if not default_list then return; end
 	local items = default_list.items;
 	local item;
@@ -53,7 +58,7 @@
 	local privacy_lists = datamanager.load(username, host, "privacy") or {};
 	local default_list_name = privacy_lists.default;
 	if not default_list_name then return; end
-	local default_list = privacy_lists.list[default_list_name];
+	local default_list = privacy_lists.lists[default_list_name];
 	if not default_list then return; end
 	local items = default_list.items;
 	local item;
@@ -71,7 +76,7 @@
 	local privacy_lists = datamanager.load(username, host, "privacy") or {};
 	local default_list_name = privacy_lists.default;
 	if not default_list_name then return {}; end
-	local default_list = privacy_lists.list[default_list_name];
+	local default_list = privacy_lists.lists[default_list_name];
 	if not default_list then return {}; end
 	local items = default_list.items;
 	local item;
@@ -89,7 +94,7 @@
 	local username, host = jid_split(stanza.attr.from);
 	if stanza.attr.type == "set" then
 		if stanza.tags[1].name == "block" then
-			local block = stanza.tags[1]:get_child("block");
+			local block = stanza.tags[1];
 			local block_jid_list = {};
 			for item in block:childtags() do
 				block_jid_list[#block_jid_list+1] = item.attr.jid;