Merging more s2s
authorMatthew Wild <mwild1@gmail.com>
Fri, 24 Oct 2008 07:36:48 +0100
changeset 150 d09b8a1ab046
parent 149 40e443eacbbd (diff)
parent 148 4c0dcd245d34 (current diff)
child 153 8310bfddaba8
Merging more s2s
core/sessionmanager.lua
core/stanza_router.lua
core/xmlhandlers.lua
main.lua
--- a/.hgtags	Fri Oct 24 07:27:36 2008 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-0000000000000000000000000000000000000000 tip
--- a/core/offlinemessage.lua	Fri Oct 24 07:27:36 2008 +0100
+++ b/core/offlinemessage.lua	Fri Oct 24 07:36:48 2008 +0100
@@ -11,3 +11,5 @@
 	t_insert(offlinedata, stanza);
 	return datamanager.store(user, host, "offlinemsg", offlinedata);
 end
+
+return _M;
\ No newline at end of file
--- a/core/rostermanager.lua	Fri Oct 24 07:27:36 2008 +0100
+++ b/core/rostermanager.lua	Fri Oct 24 07:36:48 2008 +0100
@@ -18,17 +18,6 @@
 
 module "rostermanager"
 
---[[function getroster(username, host)
-	return { 
-			["mattj@localhost"] = true,
-			["tobias@getjabber.ath.cx"] = true,
-			["waqas@getjabber.ath.cx"] = true,
-			["thorns@getjabber.ath.cx"] = true, 
-			["idw@getjabber.ath.cx"] = true, 
-		}
-	--return datamanager.load(username, host, "roster") or {};
-end]]
-
 function add_to_roster(session, jid, item)
 	if session.roster then
 		local old_item = session.roster[jid];
@@ -65,7 +54,7 @@
 		local stanza = st.iq({type="set"});
 		stanza:tag("query", {xmlns = "jabber:iq:roster"});
 		if item then
-			stanza:tag("item", {jid = jid, subscription = item.subscription, name = item.name});
+			stanza:tag("item", {jid = jid, subscription = item.subscription, name = item.name, ask = item.ask});
 			for group in pairs(item.groups) do
 				stanza:tag("group"):text(group):up();
 			end
@@ -94,6 +83,7 @@
 		return roster;
 	end
 	-- Attempt to load roster for non-loaded user
+	-- TODO also support loading for offline user
 end
 
 function save_roster(username, host)
--- a/core/stanza_router.lua	Fri Oct 24 07:27:36 2008 +0100
+++ b/core/stanza_router.lua	Fri Oct 24 07:36:48 2008 +0100
@@ -151,7 +151,6 @@
 	end
 end
 
--- TODO: Does this function belong here?
 function is_authorized_to_see_presence(origin, username, host)
 	local roster = datamanager.load(username, host, "roster") or {};
 	local item = roster[origin.username.."@"..origin.host];
--- a/doc/roster_format.txt	Fri Oct 24 07:27:36 2008 +0100
+++ b/doc/roster_format.txt	Fri Oct 24 07:36:48 2008 +0100
@@ -9,6 +9,7 @@
   string subscription = "none" | "to" | "from" | "both"
   string name = Opaque string set by client. (optional)
   set groups = a set of opaque strings set by the client
+  boolean ask = nil | "subscribe" - a value of true indicates subscription is pending
 }
 
 The roster is available as
--- a/main.lua	Fri Oct 24 07:27:36 2008 +0100
+++ b/main.lua	Fri Oct 24 07:36:48 2008 +0100
@@ -1,4 +1,4 @@
-require "luarocks.require"
+pcall(require, "luarocks.require")
 
 local server = require "net.server"
 require "lxp"
@@ -31,7 +31,7 @@
 require "util.jid"
 
 ------------------------------------------------------------------------
- 
+
 -- Locals for faster access --
 local t_insert = table.insert;
 local t_concat = table.concat;
--- a/plugins/mod_roster.lua	Fri Oct 24 07:27:36 2008 +0100
+++ b/plugins/mod_roster.lua	Fri Oct 24 07:36:48 2008 +0100
@@ -19,6 +19,7 @@
 						roster:tag("item", {
 							jid = jid,
 							subscription = session.roster[jid].subscription,
+							ask = session.roster[jid].ask,
 							name = session.roster[jid].name,
 						});
 						for group in pairs(session.roster[jid].groups) do
@@ -54,6 +55,7 @@
 									if r_item.name == "" then r_item.name = nil; end
 									if session.roster[item.attr.jid] then
 										r_item.subscription = session.roster[item.attr.jid].subscription;
+										r_item.ask = session.roster[item.attr.jid].ask;
 									else
 										r_item.subscription = "none";
 									end
--- a/util/datamanager.lua	Fri Oct 24 07:27:36 2008 +0100
+++ b/util/datamanager.lua	Fri Oct 24 07:36:48 2008 +0100
@@ -93,3 +93,4 @@
 	return true;
 end
 
+return _M;
\ No newline at end of file