Software /
code /
prosody
Changeset
110:bb5ac5976a97
Fixed: Roster support
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Wed, 22 Oct 2008 21:20:07 +0500 |
parents | 109:7efedc96352a |
children | 111:0abe771b43c6 |
files | core/rostermanager.lua plugins/mod_roster.lua |
diffstat | 2 files changed, 11 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/core/rostermanager.lua Wed Oct 22 21:18:50 2008 +0500 +++ b/core/rostermanager.lua Wed Oct 22 21:20:07 2008 +0500 @@ -7,6 +7,7 @@ local setmetatable = setmetatable; local format = string.format; local loadfile, setfenv, pcall = loadfile, setfenv, pcall; +local pairs, ipairs = pairs, ipairs; local hosts = hosts; @@ -14,7 +15,6 @@ local datamanager = datamanager; local st = require "util.stanza"; -local send = require "core.sessionmanager".send_to_session; module "rostermanager" @@ -66,19 +66,19 @@ stanza:tag("query", {xmlns = "jabber:iq:roster"}); if item then stanza:tag("item", {jid = jid, subscription = item.subscription, name = item.name}); + for group in pairs(item.groups) do + stanza:tag("group"):text(group):up(); + end else stanza:tag("item", {jid = jid, subscription = "remove"}); end - for group in item.groups do - stanza:tag("group"):text(group):up(); - end stanza:up(); stanza:up(); -- stanza ready - for _, session in ipairs(hosts[host].sessions[username].sessions) do + for _, session in pairs(hosts[host].sessions[username].sessions) do if session.full_jid then -- FIXME do we need to set stanza.attr.to? - send(session, stanza); + session.send(stanza); end end end @@ -98,7 +98,7 @@ function save_roster(username, host) if hosts[host] and hosts[host].sessions[username] and hosts[host].sessions[username].roster then - return datamanager.save(username, host, "roster", hosts[host].sessions[username].roster); + return datamanager.store(username, host, "roster", hosts[host].sessions[username].roster); end return nil; end
--- a/plugins/mod_roster.lua Wed Oct 22 21:18:50 2008 +0500 +++ b/plugins/mod_roster.lua Wed Oct 22 21:20:07 2008 +0500 @@ -6,6 +6,7 @@ local t_concat = table.concat; local rm_remove_from_roster = require "core.rostermanager".remove_from_roster; +local rm_add_to_roster = require "core.rostermanager".add_to_roster; local rm_roster_push = require "core.rostermanager".roster_push; add_iq_handler("c2s", "jabber:iq:roster", @@ -15,15 +16,14 @@ local roster = st.reply(stanza) :query("jabber:iq:roster"); for jid in pairs(session.roster) do - local item = st.stanza("item", { + roster:tag("item", { jid = jid, subscription = session.roster[jid].subscription, name = session.roster[jid].name, }); for group in pairs(session.roster[jid].groups) do - item:tag("group"):text(group):up(); + roster:tag("group"):text(group):up(); end - roster:add_child(item); end send(session, roster); return true; @@ -52,7 +52,7 @@ local r_item = {name = item.attr.name, groups = {}}; 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]; + r_item.subscription = session.roster[item.attr.jid].subscription; else r_item.subscription = "none"; end