mirror of
https://github.com/bjc/prosody.git
synced 2025-04-03 21:27:38 +03:00
Added some roster management functions
This commit is contained in:
parent
36df1aac32
commit
957fe047e2
2 changed files with 32 additions and 4 deletions
|
@ -14,7 +14,7 @@ local datamanager = datamanager;
|
|||
|
||||
module "rostermanager"
|
||||
|
||||
function getroster(username, host)
|
||||
--[[function getroster(username, host)
|
||||
return {
|
||||
["mattj@localhost"] = true,
|
||||
["tobias@getjabber.ath.cx"] = true,
|
||||
|
@ -22,7 +22,35 @@ function getroster(username, host)
|
|||
["thorns@getjabber.ath.cx"] = true,
|
||||
["idw@getjabber.ath.cx"] = true,
|
||||
}
|
||||
-- return datamanager.load(username, host, "roster") or {};
|
||||
--return datamanager.load(username, host, "roster") or {};
|
||||
end]]
|
||||
|
||||
function add_to_roster(roster, jid, item)
|
||||
roster[jid] = item;
|
||||
-- TODO implement
|
||||
end
|
||||
|
||||
function remove_from_roster(roster, jid)
|
||||
roster[jid] = nil;
|
||||
-- TODO implement
|
||||
end
|
||||
|
||||
function load_roster(host, username)
|
||||
if hosts[host] and hosts[host].sessions[username] then
|
||||
local roster = hosts[host].sessions[username].roster;
|
||||
if not roster then
|
||||
return hosts[host].sessions[username].roster = datamanger.load(username, host, "roster") or {};
|
||||
end
|
||||
return roster;
|
||||
end
|
||||
error("Attempt to load roster for non-loaded user"); --return nil;
|
||||
end
|
||||
|
||||
function save_roster(host, username)
|
||||
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);
|
||||
end
|
||||
return nil;
|
||||
end
|
||||
|
||||
return _M;
|
|
@ -12,7 +12,7 @@ local modulemanager = require "core.modulemanager";
|
|||
local log = require "util.logger".init("sessionmanager");
|
||||
local error = error;
|
||||
local uuid_generate = require "util.uuid".uuid_generate;
|
||||
local rm_getroster = require "core.rostermanager".getroster
|
||||
local rm_load_roster = require "core.rostermanager".load_roster;
|
||||
|
||||
local newproxy = newproxy;
|
||||
local getmetatable = getmetatable;
|
||||
|
@ -92,7 +92,7 @@ function bind_resource(session, resource)
|
|||
session.full_jid = session.username .. '@' .. session.host .. '/' .. resource;
|
||||
hosts[session.host].sessions[session.username].sessions[resource] = session;
|
||||
|
||||
session.roster = rm_getroster(session.username, session.host);
|
||||
session.roster = rm_load_roster(session.username, session.host);
|
||||
|
||||
return true;
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue