Roster updates
authorWaqas Hussain <waqas20@gmail.com>
Thu, 23 Oct 2008 15:02:30 +0000 (20:02 +0500)
committerWaqas Hussain <waqas20@gmail.com>
Thu, 23 Oct 2008 15:02:30 +0000 (20:02 +0500)
 - Added support for item.ask attribute in rostermanager and mod_roster
 - Updated roster docs
 - Removed old code from rostermanager

core/rostermanager.lua
doc/roster_format.txt
plugins/mod_roster.lua

index 26a142568fa247388634dc034144bf45f45bcf47..c39d28ed1b9090884cd5c1b2a6056584c9a96e6b 100644 (file)
@@ -18,17 +18,6 @@ local st = require "util.stanza";
 
 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 @@ function roster_push(username, host, jid)
                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 @@ function load_roster(username, host)
                return roster;
        end
        -- Attempt to load roster for non-loaded user
+       -- TODO also support loading for offline user
 end
 
 function save_roster(username, host)
index 73186c2bc2257eb37cd4cf9163a1487a1f81dbe2..132dbf4ebf3379b2879ed07ecdbc715d439f5d72 100644 (file)
@@ -9,7 +9,7 @@ table roster_item {
   string subscription = "none" | "to" | "from" | "both"\r
   string name = Opaque string set by client. (optional)\r
   set groups = a set of opaque strings set by the client\r
-  boolean ask = nil | true - a value of true indicates subscription is pending\r
+  boolean ask = nil | "subscribe" - a value of true indicates subscription is pending\r
 }\r
 \r
 The roster is available as\r
index 8a20f76dc181ecd888c9c2f717f19341d00b30ee..d02f77a565f271a9e224cad0af079ca5ebbf6455 100644 (file)
@@ -19,6 +19,7 @@ add_iq_handler("c2s", "jabber:iq:roster",
                                                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 @@ add_iq_handler("c2s", "jabber:iq:roster",
                                                                        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