Annotate

plugins/mod_privacy.lua @ 1711:00ad2488ef0b

Removed util/discohelper.lua
author Waqas Hussain <waqas20@gmail.com>
date Tue, 18 Aug 2009 12:58:34 +0500
parent 1522:569d58d21612
child 2496:f18b882af1d1
child 2923:b7049746bd29
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1522
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 1293
diff changeset
1 -- Prosody IM
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 1293
diff changeset
2 -- Copyright (C) 2008-2009 Matthew Wild
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 1293
diff changeset
3 -- Copyright (C) 2008-2009 Waqas Hussain
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 1293
diff changeset
4 --
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 1293
diff changeset
5 -- This project is MIT/X11 licensed. Please see the
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 1293
diff changeset
6 -- COPYING file in the source package for more information.
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 1293
diff changeset
7 --
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 1293
diff changeset
8
1293
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
9
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
10 local st = require "util.stanza";
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
11 local datamanager = require "util.datamanager";
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
12
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
13 module:hook("iq/bare/jabber:iq:privacy:query", function(data)
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
14 local origin, stanza = data.origin, data.stanza;
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
15
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
16 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
17 local query = stanza.tags[1]; -- the query element
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
18 local privacy_lists = datamanager.load(origin.username, origin.host, "privacy") or {};
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
19 if stanza.attr.type == "set" then
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
20 -- TODO
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
21 elseif stanza.attr.type == "get" then
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
22 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
23 -- TODO
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
24 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
25 -- TODO
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
26 else
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
27 origin.send(st.error_reply(stanza, "modify", "bad-request"));
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
28 end
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
29 end
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
30 end
13dde33d5b87 mod_privacy: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
31 end);