Update copyright headers for 2010
[prosody.git] / plugins / mod_privacy.lua
1 -- Prosody IM
2 -- Copyright (C) 2008-2010 Matthew Wild
3 -- Copyright (C) 2008-2010 Waqas Hussain
4 -- 
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
7 --
8
9
10 local st = require "util.stanza";
11 local datamanager = require "util.datamanager";
12
13 module:hook("iq/bare/jabber:iq:privacy:query", function(data)
14         local origin, stanza = data.origin, data.stanza;
15         
16         if not stanza.attr.to then -- only service requests to own bare JID
17                 local query = stanza.tags[1]; -- the query element
18                 local privacy_lists = datamanager.load(origin.username, origin.host, "privacy") or {};
19                 if stanza.attr.type == "set" then
20                         -- TODO
21                 elseif stanza.attr.type == "get" then
22                         if #query.tags == 0 then -- Client requests names of privacy lists from server
23                                 -- TODO
24                         elseif #query.tags == 1 and query.tags[1].name == "list" then -- Client requests a privacy list from server
25                                 -- TODO
26                         else
27                                 origin.send(st.error_reply(stanza, "modify", "bad-request"));
28                         end
29                 end
30         end
31 end);