Changeset

3115:4c35ef27d868

Merge 0.7/waqas->0.7/MattJ
author Matthew Wild <mwild1@gmail.com>
date Sun, 23 May 2010 23:05:01 +0100
parents 3107:6d576a66ca63 (current diff) 3114:75ea1aff69da (diff)
children 3116:90a98a6b52ac 3118:95ddd75ed3c5
files
diffstat 5 files changed, 15 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/core/rostermanager.lua	Sun Feb 28 22:58:43 2010 +0100
+++ b/core/rostermanager.lua	Sun May 23 23:05:01 2010 +0100
@@ -96,7 +96,7 @@
 	local data, err = datamanager.load(username, host, "roster");
 	roster = data or {};
 	if user then user.roster = roster; end
-	if not roster[false] then roster[false] = { }; end
+	if not roster[false] then roster[false] = { broken = err or nil }; end
 	if roster[jid] then
 		roster[jid] = nil;
 		log("warn", "roster for "..jid.." has a self-contact");
@@ -125,6 +125,7 @@
 		if metadata.version ~= true then
 			metadata.version = (metadata.version or 0) + 1;
 		end
+		if roster[false].broken then return nil, "Not saving broken roster" end
 		return datamanager.store(username, host, "roster", roster);
 	end
 	log("warn", "save_roster: user had no roster to save");
@@ -190,9 +191,9 @@
 end
 
 function is_contact_subscribed(username, host, jid)
-	local roster = load_roster(username, host);
+	local roster, err = load_roster(username, host);
 	local item = roster[jid];
-	return item and (item.subscription == "from" or item.subscription == "both");
+	return item and (item.subscription == "from" or item.subscription == "both"), err;
 end
 
 function is_contact_pending_in(username, host, jid)
--- a/core/usermanager.lua	Sun Feb 28 22:58:43 2010 +0100
+++ b/core/usermanager.lua	Sun May 23 23:05:01 2010 +0100
@@ -69,7 +69,8 @@
 
 function user_exists(username, host)
 	if not(require_provisioning) and is_cyrus(host) then return true; end
-	return datamanager.load(username, host, "accounts") ~= nil; -- FIXME also check for empty credentials
+	local account, err = datamanager.load(username, host, "accounts");
+	return (account or err) ~= nil; -- FIXME also check for empty credentials
 end
 
 function create_user(username, password, host)
--- a/plugins/mod_presence.lua	Sun Feb 28 22:58:43 2010 +0100
+++ b/plugins/mod_presence.lua	Sun May 23 23:05:01 2010 +0100
@@ -227,16 +227,13 @@
 	stanza.attr.from, stanza.attr.to = from_bare, to_bare;
 	log("debug", "inbound presence "..stanza.attr.type.." from "..from_bare.." for "..to_bare);
 	
-	if not node then
-		log("debug", "dropping presence sent to host or invalid address '%s'", tostring(to_bare));
-	end
-	
 	if stanza.attr.type == "probe" then
-		if rostermanager.is_contact_subscribed(node, host, from_bare) then
+		local result, err = rostermanager.is_contact_subscribed(node, host, from_bare);
+		if result then
 			if 0 == send_presence_of_available_resources(node, host, st_from, origin, core_route_stanza) then
 				core_route_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="unavailable"})); -- TODO send last activity
 			end
-		else
+		elseif not err then
 			core_route_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="unsubscribed"}));
 		end
 	elseif stanza.attr.type == "subscribe" then
--- a/plugins/mod_private.lua	Sun Feb 28 22:58:43 2010 +0100
+++ b/plugins/mod_private.lua	Sun May 23 23:05:01 2010 +0100
@@ -26,7 +26,11 @@
 				if #query.tags == 1 then
 					local tag = query.tags[1];
 					local key = tag.name..":"..tag.attr.xmlns;
-					local data = datamanager.load(node, host, "private");
+					local data, err = datamanager.load(node, host, "private");
+					if err then
+						session.send(st.error_reply(stanza, "wait", "internal-server-error"));
+						return true;
+					end
 					if stanza.attr.type == "get" then
 						if data and data[key] then
 							session.send(st.reply(stanza):tag("query", {xmlns = "jabber:iq:private"}):add_child(st.deserialize(data[key])));
--- a/util/datamanager.lua	Sun Feb 28 22:58:43 2010 +0100
+++ b/util/datamanager.lua	Sun May 23 23:05:01 2010 +0100
@@ -145,7 +145,7 @@
 	local f, msg = io_open(getpath(username, host, datastore, nil, true), "w+");
 	if not f then
 		log("error", "Unable to write to "..datastore.." storage ('"..msg.."') for user: "..(username or "nil").."@"..(host or "nil"));
-		return;
+		return nil, "Error saving to storage";
 	end
 	f:write("return ");
 	append(f, data);