Annotate

mod_privacy/mod_privacy.lua @ 27:d91cb13ef0ee

mod_privacy: make the block function work; retrieve the roster groups correctly
author Thilo Cestonaro <thilo@cestona.ro>
date Fri, 09 Oct 2009 23:23:12 +0200
parent 20:2675dc25445b
child 39:b84b2b026eb4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
1 -- Prosody IM
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
2 -- Copyright (C) 2008-2009 Matthew Wild
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
3 -- Copyright (C) 2008-2009 Waqas Hussain
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
4 -- Copyright (C) 2009 Thilo Cestonaro
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
5 --
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
6 -- This project is MIT/X11 licensed. Please see the
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
7 -- COPYING file in the source package for more information.
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
8 --
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
9
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
10 local prosody = prosody;
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
11 local st = require "util.stanza";
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
12 local datamanager = require "util.datamanager";
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
13 local bare_sessions = bare_sessions;
11
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
14 local util_Jid = require "util.jid";
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
15 local jid_bare = util_Jid.bare;
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
16 local jid_split = util_Jid.split;
16
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
17 local load_roster = require "core.rostermanager".load_roster;
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
18 local to_number = _G.tonumber;
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
19
10
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
20 function findNamedList (privacy_lists, name)
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
21 local ret = nil
11
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
22 if privacy_lists.lists == nil then
27
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
23 module:log("debug", "privacy_lists.list is nil. no lists loaded.")
11
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
24 return nil;
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
25 end
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
26
11
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
27 module:log("debug", "searching for list: %s", name);
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
28 for i=1, #privacy_lists.lists do
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
29 if privacy_lists.lists[i].name == name then
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
30 ret = i;
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
31 break;
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
32 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
33 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
34 return ret;
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
35 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
36
20
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
37 function isListUsed(origin, name, privacy_lists)
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
38 if bare_sessions[origin.username.."@"..origin.host].sessions ~= nil then
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
39 for resource, session in pairs(bare_sessions[origin.username.."@"..origin.host].sessions) do
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
40 if resource ~= origin.resource then
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
41 if session.activePrivacyList == name then
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
42 module:log("debug", "List {0} is in use.", name);
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
43 return true;
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
44 elseif session.activePrivacyList == nil and privacy_lists.default == name then
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
45 module:log("debug", "List {0} is in use.", name);
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
46 return true;
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
47 end
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
48 end
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
49 end
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
50 end
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
51 module:log("debug", "List {0} is in NOT use.", name);
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
52 return false;
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
53 end
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
54
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
55 function isAnotherSessionUsingDefaultList(origin)
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
56 local ret = false
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
57 if bare_sessions[origin.username.."@"..origin.host].sessions ~= nil then
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
58 for resource, session in pairs(bare_sessions[origin.username.."@"..origin.host].sessions) do
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
59 if resource ~= origin.resource and session.activePrivacyList == nil then
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
60 module:log("debug", "Default list is used by another resource.");
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
61 ret = true;
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
62 break;
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
63 end
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
64 end
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
65 end
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
66 return ret;
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
67 end
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
68
10
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
69 function declineList (privacy_lists, origin, stanza, which)
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
70 module:log("info", "User requests to decline the use of privacy list: %s", which);
17
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
71 if which == "default" then
20
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
72 if isAnotherSessionUsingDefaultList(origin) then
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
73 return { "cancel", "conflict", "Another session is online and using the default list."};
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
74 end
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
75 privacy_lists.default = nil;
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
76 origin.send(st.reply(stanza));
17
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
77 elseif which == "active" then
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
78 origin.activePrivacyList = nil;
20
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
79 origin.send(st.reply(stanza));
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
80 else
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
81 return {"modify", "bad-request", "Neither default nor active list specifed to decline."};
17
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
82 end
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
83 return true;
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
84 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
85
10
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
86 function activateList (privacy_lists, origin, stanza, which, name)
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
87 module:log("info", "User requests to change the privacy list: %s, to be list named %s", which, name);
10
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
88 local idx = findNamedList(privacy_lists, name);
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
89
20
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
90 if privacy_lists.default == nil then
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
91 privacy_lists.default = "";
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
92 end
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
93 if origin.activePrivacyList == nil then
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
94 origin.activePrivacyList = "";
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
95 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
96
20
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
97 if which == "default" and idx ~= nil then
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
98 if isAnotherSessionUsingDefaultList(origin) then
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
99 return {"cancel", "conflict", "Another session is online and using the default list."};
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
100 end
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
101 privacy_lists.default = name;
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
102 origin.send(st.reply(stanza));
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
103 elseif which == "active" and idx ~= nil then
17
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
104 origin.activePrivacyList = name;
20
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
105 origin.send(st.reply(stanza));
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
106 else
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
107 return {"modify", "bad-request", "Either not active or default given or unknown list name specified."};
17
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
108 end
20
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
109 return true;
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
110 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
111
10
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
112 function deleteList (privacy_lists, origin, stanza, name)
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
113 module:log("info", "User requests to delete privacy list: %s", name);
10
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
114 local idx = findNamedList(privacy_lists, name);
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
115
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
116 if idx ~= nil then
20
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
117 if isListUsed(origin, name, privacy_lists) then
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
118 return {"cancel", "conflict", "Another session is online and using the list which should be deleted."};
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
119 end
27
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
120 if privacy_lists.default == name then
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
121 privacy_lists.default = "";
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
122 end
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
123 if origin.activePrivacyList == name then
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
124 origin.activePrivacyList = "";
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
125 end
20
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
126 table.remove(privacy_lists.lists, idx);
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
127 origin.send(st.reply(stanza));
20
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
128 return true;
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
129 end
20
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
130 return {"modify", "bad-request", "Not existing list specifed to be deleted."};
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
131 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
132
10
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
133 local function sortByOrder(a, b)
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
134 if a.order < b.order then
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
135 return true;
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
136 end
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
137 return false;
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
138 end
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
139
16
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
140 function createOrReplaceList (privacy_lists, origin, stanza, name, entries, roster)
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
141 module:log("info", "User requests to create / replace list named %s, item count: %d", name, #entries);
10
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
142 local idx = findNamedList(privacy_lists, name);
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
143 local bare_jid = origin.username.."@"..origin.host;
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
144
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
145 if privacy_lists.lists == nil then
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
146 privacy_lists.lists = {};
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
147 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
148
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
149 if idx == nil then
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
150 idx = #privacy_lists.lists + 1;
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
151 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
152
16
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
153 local orderCheck = {};
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
154 local list = {};
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
155 list.name = name;
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
156 list.items = {};
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
157
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
158 for _,item in ipairs(entries) do
16
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
159 if to_number(item.attr.order) == nil or to_number(item.attr.order) < 0 or orderCheck[item.attr.order] ~= nil then
20
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
160 return {"modify", "bad-request", "Order attribute not valid."};
16
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
161 end
20
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
162
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
163 if item.attr.type ~= nil and item.attr.type ~= "jid" and item.attr.type ~= "subscription" and item.attr.type ~= "group" then
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
164 return {"modify", "bad-request", "Type attribute not valid."};
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
165 end
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
166
14
0892941186f2 mod_privacy: Make tmp variable a local
Matthew Wild <mwild1@gmail.com>
parents: 10
diff changeset
167 local tmp = {};
16
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
168 orderCheck[item.attr.order] = true;
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
169
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
170 tmp["type"] = item.attr.type;
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
171 tmp["value"] = item.attr.value;
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
172 tmp["action"] = item.attr.action;
16
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
173 tmp["order"] = to_number(item.attr.order);
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
174 tmp["presence-in"] = false;
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
175 tmp["presence-out"] = false;
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
176 tmp["message"] = false;
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
177 tmp["iq"] = false;
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
178
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
179 if #item.tags > 0 then
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
180 for _,tag in ipairs(item.tags) do
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
181 tmp[tag.name] = true;
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
182 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
183 end
16
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
184
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
185 if tmp.type == "group" then
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
186 local found = false;
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
187 local roster = load_roster(origin.username, origin.host);
27
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
188 for jid,item in pairs(roster) do
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
189 if item.groups ~= nil then
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
190 for group in pairs(item.groups) do
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
191 if group == tmp.value then
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
192 found = true;
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
193 break;
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
194 end
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
195 end
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
196 if found == true then
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
197 break;
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
198 end
16
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
199 end
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
200 end
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
201 if found == false then
20
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
202 return {"cancel", "item-not-found", "Specifed roster group not existing."};
16
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
203 end
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
204 elseif tmp.type == "subscription" then
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
205 if tmp.value ~= "both" and
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
206 tmp.value ~= "to" and
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
207 tmp.value ~= "from" and
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
208 tmp.value ~= "none" then
20
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
209 return {"cancel", "bad-request", "Subscription value must be both, to, from or none."};
16
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
210 end
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
211 end
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
212
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
213 if tmp.action ~= "deny" and tmp.action ~= "allow" then
20
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
214 return {"cancel", "bad-request", "Action must be either deny or allow."};
16
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
215 end
35e74c1094a7 mod_privacy: order must be non-negativ integer and unique, group must be existing in the roster, subscription can only be to,from,both or none, action must be either deny or allow.
Thilo Cestonaro <thilo@cestona.ro>
parents: 15
diff changeset
216
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
217 list.items[#list.items + 1] = tmp;
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
218 end
10
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
219
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
220 table.sort(list, sortByOrder);
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
221
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
222 privacy_lists.lists[idx] = list;
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
223 origin.send(st.reply(stanza));
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
224 if bare_sessions[bare_jid] ~= nil then
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
225 iq = st.iq ( { type = "set", id="push1" } );
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
226 iq:tag ("query", { xmlns = "jabber:iq:privacy" } );
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
227 iq:tag ("list", { name = list.name } ):up();
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
228 iq:up();
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
229 for resource, session in pairs(bare_sessions[bare_jid].sessions) do
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
230 iq.attr.to = bare_jid.."/"..resource
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
231 session.send(iq);
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
232 end
20
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
233 else
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
234 return {"cancel", "bad-request", "internal error."};
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
235 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
236 return true;
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
237 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
238
10
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
239 function getList(privacy_lists, origin, stanza, name)
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
240 module:log("info", "User requests list named: %s", name or "nil");
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
241 local reply = st.reply(stanza);
10
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
242 reply:tag("query", {xmlns="jabber:iq:privacy"});
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
243
10
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
244 if name == nil then
17
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
245 reply:tag("active", {name=origin.activePrivacyList or ""}):up();
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
246 reply:tag("default", {name=privacy_lists.default or ""}):up();
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
247 if privacy_lists.lists then
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
248 for _,list in ipairs(privacy_lists.lists) do
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
249 reply:tag("list", {name=list.name}):up();
10
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
250 end
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
251 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
252 else
10
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
253 local idx = findNamedList(privacy_lists, name);
11
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
254 module:log("debug", "list idx: %d", idx or -1);
10
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
255 if idx ~= nil then
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
256 list = privacy_lists.lists[idx];
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
257 reply = reply:tag("list", {name=list.name});
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
258 for _,item in ipairs(list.items) do
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
259 reply:tag("item", {type=item.type, value=item.value, action=item.action, order=item.order});
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
260 if item["message"] then reply:tag("message"):up(); end
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
261 if item["iq"] then reply:tag("iq"):up(); end
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
262 if item["presence-in"] then reply:tag("presence-in"):up(); end
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
263 if item["presence-out"] then reply:tag("presence-out"):up(); end
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
264 reply:up();
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
265 end
20
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
266 else
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
267 return {"cancel", "item-not-found", "Unknown list specified."};
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
268 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
269 end
20
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
270
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
271 origin.send(reply);
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
272 return true;
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
273 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
274
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
275 module:hook("iq/bare/jabber:iq:privacy:query", function(data)
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
276 local origin, stanza = data.origin, data.stanza;
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
277
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
278 if stanza.attr.to == nil then -- only service requests to own bare JID
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
279 local query = stanza.tags[1]; -- the query element
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
280 local valid = false;
10
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
281 local privacy_lists = datamanager.load(origin.username, origin.host, "privacy") or {};
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
282
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
283 if stanza.attr.type == "set" then
17
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
284 if #query.tags == 1 then -- the <query/> element MUST NOT include more than one child element
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
285 for _,tag in ipairs(query.tags) do
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
286 if tag.name == "active" or tag.name == "default" then
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
287 if tag.attr.name == nil then -- Client declines the use of active / default list
10
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
288 valid = declineList(privacy_lists, origin, stanza, tag.name);
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
289 else -- Client requests change of active / default list
10
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
290 valid = activateList(privacy_lists, origin, stanza, tag.name, tag.attr.name);
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
291 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
292 elseif tag.name == "list" and tag.attr.name then -- Client adds / edits a privacy list
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
293 if #tag.tags == 0 then -- Client removes a privacy list
10
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
294 valid = deleteList(privacy_lists, origin, stanza, tag.attr.name);
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
295 else -- Client edits a privacy list
17
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
296 valid = createOrReplaceList(privacy_lists, origin, stanza, tag.attr.name, tag.tags); -- TODO check if used!
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
297 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
298 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
299 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
300 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
301 elseif stanza.attr.type == "get" then
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
302 local name = nil;
10
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
303 local listsToRetrieve = 0;
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
304 if #query.tags >= 1 then
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
305 for _,tag in ipairs(query.tags) do
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
306 if tag.name == "list" then -- Client requests a privacy list from server
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
307 name = tag.attr.name;
10
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
308 listsToRetrieve = listsToRetrieve + 1;
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
309 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
310 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
311 end
10
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
312 if listsToRetrieve == 0 or listsToRetrieve == 1 then
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
313 valid = getList(privacy_lists, origin, stanza, name);
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
314 end
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
315 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
316
20
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
317 if valid ~= true then
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
318 if valid[0] == nil then
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
319 valid[0] = "cancel";
10
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
320 end
20
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
321 if valid[1] == nil then
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
322 valid[1] = "bad-request";
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
323 end
2675dc25445b mod_privacy: overworked error returns while creating, editing, deleting or de/activating lists.
Thilo Cestonaro <thilo@cestona.ro>
parents: 19
diff changeset
324 origin.send(st.error_reply(stanza, valid[0], valid[1], valid[2]));
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
325 else
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
326 datamanager.store(origin.username, origin.host, "privacy", privacy_lists);
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
327 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
328 return true;
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
329 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
330 return false;
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
331 end, 500);
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
332
17
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
333 function checkIfNeedToBeBlocked(e, session)
27
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
334
10
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
335 local origin, stanza = e.origin, e.stanza;
17
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
336 local privacy_lists = datamanager.load(session.username, session.host, "privacy") or {};
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
337 local bare_jid = session.username.."@"..session.host;
11
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
338
27
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
339 -- module:log("debug", "Where are we from: %s", debug.traceback())
17
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
340 module:log("debug", "checkIfNeedToBeBlocked: username: %s, host: %s", session.username, session.host);
11
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
341 module:log("debug", "stanza: %s, to: %s, form: %s", stanza.name, stanza.attr.to or "nil", stanza.attr.from or "nil");
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
342
27
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
343 if stanza.attr.to ~= nil and stanza.attr.from ~= nil then
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
344 module:log("debug", "privacy_lists.lists: %s", tostring(privacy_lists.lists));
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
345 module:log("debug", "session.activePrivacyList: %s", tostring(session.activePrivacyList));
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
346 module:log("debug", "privacy_lists.default: %s", tostring(privacy_lists.default));
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
347 if privacy_lists.lists == nil or
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
348 (session.activePrivacyList == nil or session.activePrivacyList == "") and
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
349 (privacy_lists.default == nil or privacy_lists.default == "")
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
350 then
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
351 module:log("debug", "neither active nor default list set (both are nil) or privacy_lists totally nil. So nothing to do => default is Allow All.");
11
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
352 return; -- Nothing to block, default is Allow all
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
353 end
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
354
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
355 local idx;
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
356 local list;
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
357 local item;
17
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
358 local listname = session.activePrivacyList;
27
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
359 if listname == nil or listname == "" then
11
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
360 listname = privacy_lists.default; -- no active list selected, use default list
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
361 end
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
362 idx = findNamedList(privacy_lists, listname);
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
363 if idx == nil then
27
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
364 module:log("error", "given privacy listname not found. name: %s", listname);
11
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
365 return;
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
366 end
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
367 list = privacy_lists.lists[idx];
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
368 if list == nil then
27
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
369 module:log("info", "privacy list index wrong. index: %d", idx);
11
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
370 return;
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
371 end
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
372 for _,item in ipairs(list.items) do
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
373 local apply = false;
17
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
374 local block = false;
27
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
375 if (stanza.name == "message" and item.message) then
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
376 module:log("debug", "message stanza match.");
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
377 apply = true;
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
378 elseif (stanza.name == "iq" and item.iq) then
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
379 module:log("debug", "iq stanza match!");
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
380 apply = true;
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
381 elseif (stanza.name == "presence" and jid_bare(stanza.attr.to) == bare_jid and item["presence-in"]) then
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
382 module:log("debug", "presence-in stanza match.");
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
383 apply = true;
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
384 elseif (stanza.name == "presence" and jid_bare(stanza.attr.from) == bare_jid and item["presence-out"]) then
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
385 module:log("debug", "presence-out stanza match");
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
386 apply = true;
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
387 elseif (item.message == false and item.iq == false and item["presence-in"] == false and item["presence-in"] == false) then
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
388 module:log("debug", "all is false, so apply.");
17
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
389 apply = true;
11
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
390 end
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
391 if apply then
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
392 local evilJid = {};
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
393 apply = false;
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
394 if jid_bare(stanza.attr.to) == bare_jid then
27
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
395 module:log("debug", "evil jid is (from): %s", stanza.attr.from);
11
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
396 evilJid.node, evilJid.host, evilJid.resource = jid_split(stanza.attr.from);
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
397 else
27
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
398 module:log("debug", "evil jid is (to): %s", stanza.attr.to);
11
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
399 evilJid.node, evilJid.host, evilJid.resource = jid_split(stanza.attr.to);
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
400 end
27
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
401 module:log("debug", "Item Type: %s", tostring(item.type));
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
402 module:log("debug", "Item Action: %s", item.action);
11
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
403 if item.type == "jid" and
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
404 (evilJid.node and evilJid.host and evilJid.resource and item.value == evilJid.node.."@"..evilJid.host.."/"..evilJid.resource) or
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
405 (evilJid.node and evilJid.host and item.value == evilJid.node.."@"..evilJid.host) or
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
406 (evilJid.host and evilJid.resource and item.value == evilJid.host.."/"..evilJid.resource) or
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
407 (evilJid.host and item.value == evilJid.host) then
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
408 module:log("debug", "jid matched.");
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
409 apply = true;
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
410 block = (item.action == "deny");
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
411 elseif item.type == "group" then
17
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
412 local roster = load_roster(session.username, session.host);
27
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
413 local groups = roster[evilJid.node .. "@" .. evilJid.host].groups;
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
414 for group in pairs(groups) do
11
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
415 if group == item.value then
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
416 module:log("debug", "group matched.");
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
417 apply = true;
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
418 block = (item.action == "deny");
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
419 break;
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
420 end
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
421 end
27
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
422 elseif item.type == "subscription" and evilJid.node ~= nil and evilJid.host ~= nil then -- we need a valid bare evil jid
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
423 local roster = load_roster(session.username, session.host);
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
424 if roster[evilJid.node .. "@" .. evilJid.host].subscription == item.value then
11
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
425 module:log("debug", "subscription matched.");
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
426 apply = true;
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
427 block = (item.action == "deny");
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
428 end
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
429 elseif item.type == nil then
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
430 module:log("debug", "no item.type, so matched.");
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
431 apply = true;
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
432 block = (item.action == "deny");
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
433 end
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
434 end
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
435 if apply then
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
436 if block then
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
437 module:log("info", "stanza blocked: %s, to: %s, from: %s", stanza.name, stanza.attr.to or "nil", stanza.attr.from or "nil");
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
438 if stanza.name == "message" then
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
439 origin.send(st.error_reply(stanza, "cancel", "service-unavailable"));
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
440 elseif stanza.name == "iq" and (stanza.attr.type == "get" or stanza.attr.type == "set") then
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
441 origin.send(st.error_reply(stanza, "cancel", "service-unavailable"));
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
442 end
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
443 return true; -- stanza blocked !
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
444 else
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
445 module:log("info", "stanza explicit allowed!")
27
d91cb13ef0ee mod_privacy: make the block function work; retrieve the roster groups correctly
Thilo Cestonaro <thilo@cestona.ro>
parents: 20
diff changeset
446 return;
11
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
447 end
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
448 end
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
449 end
10
7d70faba234c some error reporting during list editing
Thilo Cestonaro <thilo@cestona.ro>
parents: 8
diff changeset
450 end
11
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
451 return;
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
452 end
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
453
11
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
454 function preCheckIncoming(e)
17
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
455 local session;
11
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
456 if e.stanza.attr.to ~= nil then
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
457 local node, host, resource = jid_split(e.stanza.attr.to);
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
458 if node == nil or host == nil then
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
459 return;
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
460 end
17
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
461 if resource == nil then
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
462 local prio = 0;
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
463 local session_;
18
2df11ec081fe mod_privacy: make finding the right session working
Thilo Cestonaro <thilo@cestona.ro>
parents: 17
diff changeset
464 if bare_sessions[node.."@"..host] ~= nil then
2df11ec081fe mod_privacy: make finding the right session working
Thilo Cestonaro <thilo@cestona.ro>
parents: 17
diff changeset
465 for resource, session_ in pairs(bare_sessions[node.."@"..host].sessions) do
2df11ec081fe mod_privacy: make finding the right session working
Thilo Cestonaro <thilo@cestona.ro>
parents: 17
diff changeset
466 if session_.priority > prio then
2df11ec081fe mod_privacy: make finding the right session working
Thilo Cestonaro <thilo@cestona.ro>
parents: 17
diff changeset
467 session = session_;
2df11ec081fe mod_privacy: make finding the right session working
Thilo Cestonaro <thilo@cestona.ro>
parents: 17
diff changeset
468 prio = session_.priority;
2df11ec081fe mod_privacy: make finding the right session working
Thilo Cestonaro <thilo@cestona.ro>
parents: 17
diff changeset
469 end
17
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
470 end
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
471 end
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
472 else
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
473 session = full_sessions[node.."@"..host.."/"..resource];
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
474 end
18
2df11ec081fe mod_privacy: make finding the right session working
Thilo Cestonaro <thilo@cestona.ro>
parents: 17
diff changeset
475 if session ~= nil then
2df11ec081fe mod_privacy: make finding the right session working
Thilo Cestonaro <thilo@cestona.ro>
parents: 17
diff changeset
476 return checkIfNeedToBeBlocked(e, session);
2df11ec081fe mod_privacy: make finding the right session working
Thilo Cestonaro <thilo@cestona.ro>
parents: 17
diff changeset
477 else
2df11ec081fe mod_privacy: make finding the right session working
Thilo Cestonaro <thilo@cestona.ro>
parents: 17
diff changeset
478 module:log("debug", "preCheckIncoming: Couldn't get session for jid: %s@%s/%s", node or "nil", host or "nil", resource or "nil")
2df11ec081fe mod_privacy: make finding the right session working
Thilo Cestonaro <thilo@cestona.ro>
parents: 17
diff changeset
479 end
11
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
480 end
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
481 return;
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
482 end
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
483
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
484 function preCheckOutgoing(e)
17
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
485 local session;
11
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
486 if e.stanza.attr.from ~= nil then
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
487 local node, host, resource = jid_split(e.stanza.attr.from);
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
488 if node == nil or host == nil then
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
489 return;
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
490 end
17
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
491 if resource == nil then
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
492 local prio = 0;
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
493 local session_;
18
2df11ec081fe mod_privacy: make finding the right session working
Thilo Cestonaro <thilo@cestona.ro>
parents: 17
diff changeset
494 if bare_sessions[node.."@"..host] ~= nil then
2df11ec081fe mod_privacy: make finding the right session working
Thilo Cestonaro <thilo@cestona.ro>
parents: 17
diff changeset
495 for resource, session_ in pairs(bare_sessions[node.."@"..host].sessions) do
2df11ec081fe mod_privacy: make finding the right session working
Thilo Cestonaro <thilo@cestona.ro>
parents: 17
diff changeset
496 if session_.priority > prio then
2df11ec081fe mod_privacy: make finding the right session working
Thilo Cestonaro <thilo@cestona.ro>
parents: 17
diff changeset
497 session = session_;
2df11ec081fe mod_privacy: make finding the right session working
Thilo Cestonaro <thilo@cestona.ro>
parents: 17
diff changeset
498 prio = session_.priority;
2df11ec081fe mod_privacy: make finding the right session working
Thilo Cestonaro <thilo@cestona.ro>
parents: 17
diff changeset
499 end
17
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
500 end
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
501 end
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
502 else
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
503 session = full_sessions[node.."@"..host.."/"..resource];
ccb07c0efc7e mod_privacy: prepare everything for the "is used" checking stuff...
Thilo Cestonaro <thilo@cestona.ro>
parents: 16
diff changeset
504 end
18
2df11ec081fe mod_privacy: make finding the right session working
Thilo Cestonaro <thilo@cestona.ro>
parents: 17
diff changeset
505 if session ~= nil then
2df11ec081fe mod_privacy: make finding the right session working
Thilo Cestonaro <thilo@cestona.ro>
parents: 17
diff changeset
506 return checkIfNeedToBeBlocked(e, session);
2df11ec081fe mod_privacy: make finding the right session working
Thilo Cestonaro <thilo@cestona.ro>
parents: 17
diff changeset
507 else
2df11ec081fe mod_privacy: make finding the right session working
Thilo Cestonaro <thilo@cestona.ro>
parents: 17
diff changeset
508 module:log("debug", "preCheckOutgoing: Couldn't get session for jid: %s@%s/%s", node or "nil", host or "nil", resource or "nil")
2df11ec081fe mod_privacy: make finding the right session working
Thilo Cestonaro <thilo@cestona.ro>
parents: 17
diff changeset
509 end
11
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
510 end
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
511 return;
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
512 end
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
513
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
514
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
515 module:hook("pre-message/full", preCheckOutgoing, 500);
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
516 module:hook("pre-message/bare", preCheckOutgoing, 500);
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
517 module:hook("pre-message/host", preCheckOutgoing, 500);
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
518 module:hook("pre-iq/full", preCheckOutgoing, 500);
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
519 module:hook("pre-iq/bare", preCheckOutgoing, 500);
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
520 module:hook("pre-iq/host", preCheckOutgoing, 500);
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
521 module:hook("pre-presence/full", preCheckOutgoing, 500);
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
522 module:hook("pre-presence/bare", preCheckOutgoing, 500);
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
523 module:hook("pre-presence/host", preCheckOutgoing, 500);
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
524
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
525 module:hook("message/full", preCheckIncoming, 500);
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
526 module:hook("message/bare", preCheckIncoming, 500);
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
527 module:hook("message/host", preCheckIncoming, 500);
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
528 module:hook("iq/full", preCheckIncoming, 500);
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
529 module:hook("iq/bare", preCheckIncoming, 500);
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
530 module:hook("iq/host", preCheckIncoming, 500);
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
531 module:hook("presence/full", preCheckIncoming, 500);
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
532 module:hook("presence/bare", preCheckIncoming, 500);
529819205379 do the first real blocking actions
Thilo Cestonaro <thilo@cestona.ro>
parents: 10
diff changeset
533 module:hook("presence/host", preCheckIncoming, 500);
8
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
534
10502594a49b adds mod_privacy; lists creating, editing and deletion working.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
535 module:log("info", "mod_privacy loaded ...");