plugins/mod_roster.lua
author Waqas Hussain <waqas20@gmail.com>
Sun, 12 Oct 2008 17:41:14 +0500
changeset 102 a5b914370db5
parent 79 2766e23c4d7d
child 108 1d79da482c5d
permissions -rw-r--r--
Fixed: mod_roster now outputs all roster data (instead of just the JIDs)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     1
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     2
local st = require "util.stanza"
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     3
local send = require "core.sessionmanager".send_to_session
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     4
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     5
add_iq_handler("c2s", "jabber:iq:roster", 
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     6
		function (session, stanza)
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     7
			if stanza.attr.type == "get" then
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     8
				local roster = st.reply(stanza)
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     9
							:query("jabber:iq:roster");
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    10
				for jid in pairs(session.roster) do
102
a5b914370db5 Fixed: mod_roster now outputs all roster data (instead of just the JIDs)
Waqas Hussain <waqas20@gmail.com>
parents: 79
diff changeset
    11
					local item = st.stanza("item", {
a5b914370db5 Fixed: mod_roster now outputs all roster data (instead of just the JIDs)
Waqas Hussain <waqas20@gmail.com>
parents: 79
diff changeset
    12
						jid = jid,
a5b914370db5 Fixed: mod_roster now outputs all roster data (instead of just the JIDs)
Waqas Hussain <waqas20@gmail.com>
parents: 79
diff changeset
    13
						subscription = session.roster[jid].subscription,
a5b914370db5 Fixed: mod_roster now outputs all roster data (instead of just the JIDs)
Waqas Hussain <waqas20@gmail.com>
parents: 79
diff changeset
    14
						name = session.roster[jid].name,
a5b914370db5 Fixed: mod_roster now outputs all roster data (instead of just the JIDs)
Waqas Hussain <waqas20@gmail.com>
parents: 79
diff changeset
    15
					});
a5b914370db5 Fixed: mod_roster now outputs all roster data (instead of just the JIDs)
Waqas Hussain <waqas20@gmail.com>
parents: 79
diff changeset
    16
					for group in pairs(session.roster[jid].groups) do
a5b914370db5 Fixed: mod_roster now outputs all roster data (instead of just the JIDs)
Waqas Hussain <waqas20@gmail.com>
parents: 79
diff changeset
    17
						item:tag("group"):text(group):up();
a5b914370db5 Fixed: mod_roster now outputs all roster data (instead of just the JIDs)
Waqas Hussain <waqas20@gmail.com>
parents: 79
diff changeset
    18
					end
a5b914370db5 Fixed: mod_roster now outputs all roster data (instead of just the JIDs)
Waqas Hussain <waqas20@gmail.com>
parents: 79
diff changeset
    19
					roster:add_child(item);
30
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    20
				end
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    21
				send(session, roster);
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    22
				return true;
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    23
			end
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    24
		end);