Annotate

plugins/mod_privacy.lua @ 1293:13dde33d5b87

mod_privacy: Initial commit
author Waqas Hussain <waqas20@gmail.com>
date Wed, 03 Jun 2009 08:02:24 +0500
child 1522:569d58d21612
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1293
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
1
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
2 local st = require "util.stanza";
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
3 local datamanager = require "util.datamanager";
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
4
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
5 module:hook("iq/bare/jabber:iq:privacy:query", function(data)
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
6 local origin, stanza = data.origin, data.stanza;
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
7
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
8 if not stanza.attr.to then -- only service requests to own bare JID
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
9 local query = stanza.tags[1]; -- the query element
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
10 local privacy_lists = datamanager.load(origin.username, origin.host, "privacy") or {};
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
11 if stanza.attr.type == "set" then
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
12 -- TODO
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
13 elseif stanza.attr.type == "get" then
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
14 if #query.tags == 0 then -- Client requests names of privacy lists from server
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
15 -- TODO
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
16 elseif #query.tags == 1 and query.tags[1].name == "list" then -- Client requests a privacy list from server
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
17 -- TODO
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
18 else
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
19 origin.send(st.error_reply(stanza, "modify", "bad-request"));
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
20 end
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
21 end
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
22 end
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
23 end);