aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_roster.lua
blob: 6d98176186397ba1d9887f28939cf7a545b40d00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

local st = require "util.stanza"
local send = require "core.sessionmanager".send_to_session

add_iq_handler("c2s", "jabber:iq:roster", 
		function (session, stanza)
			if stanza.attr.type == "get" then
				local roster = st.reply(stanza)
							:query("jabber:iq:roster");
				for jid in pairs(session.roster) do
					local item = st.stanza("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();
					end
					roster:add_child(item);
				end
				send(session, roster);
				return true;
			end
		end);