Mercurial > psgxs
annotate modules/mod_manage.js @ 54:c2c9c06d6e9d
Fix problems with unneeded text nodes.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 06 May 2011 17:51:15 +0200 |
parents | c979c4d0932b |
children | b98e545a94f7 |
rev | line source |
---|---|
43
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
1 /* |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
2 * Copyright (C) 2010 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
3 * |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
4 * This file is part of PSĜS, a PubSub server written in JavaScript. |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
5 * |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
6 * PSĜS is free software: you can redistribute it and/or modify |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
7 * it under the terms of the GNU Affero General Public License as |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
8 * published by the Free Software Foundation, either version 3 of the |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
9 * License. |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
10 * |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
11 * PSĜS is distributed in the hope that it will be useful, |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
14 * GNU Affero General Public License for more details. |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
15 * |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
16 * You should have received a copy of the GNU Affero General Public License |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
17 * along with PSĜS. If not, see <http://www.gnu.org/licenses/>. |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
18 */ |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
19 |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
20 'use strict'; |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
41
diff
changeset
|
21 |
24
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
22 // SECTION 8.8.1: Retrieve Subscriptions List |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
23 exports.manageRetrieveSub = { |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
24 type: 'get', |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
25 child: 'pubsub', |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
26 ns: NS.PUBSUB_OWNER, |
30
b2faacfefb90
Rewrite of the module manager; fix of some modules; fix of the directory backend.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
24
diff
changeset
|
27 child2: 'subscriptions', |
24
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
28 func: function(response, stanza, request, to) { |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
29 if (!config.enabled('manage-subscriptions')) |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
30 return makeError(response, errors.owner.manage_subscriptions.not_supported.n); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
31 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
32 var nodeID = request.getAttribute('node'); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
33 if (!nodeID || nodeID == '') |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
34 return makeError(response, errors.nodeid_required.n); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
35 if (!storage.existsNode(nodeID)) |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
36 return makeError(response, errors.node_does_not_exist.n); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
37 |
47
0d3f18bb1d36
Remove usage of fdsq.js in modules.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
43
diff
changeset
|
38 var affil = storage.getAffiliation(JID.toBare(to), nodeID); |
24
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
39 if (affil != 'super-owner' && affil != 'owner') |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
40 return makeError(response, errors.forbidden.n); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
41 |
41
bc717575e66a
Much better handling of modules.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
35
diff
changeset
|
42 response.c('pubsub', {xmlns: NS.PUBSUB_OWNER}) |
bc717575e66a
Much better handling of modules.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
35
diff
changeset
|
43 .c('subscriptions', {node: nodeID}); |
24
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
44 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
45 var subs = storage.getSubscriptionsFromNodeID(nodeID) |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
46 for (var jid in subs) |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
47 response.c('subscription', {jid: jid, subscription: subs[jid].type, subid: subs[jid].subid}).up(); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
48 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
49 return response; |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
50 } |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
51 } |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
52 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
53 // SECTION 8.9.1: Retrieve Affiliations List |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
54 exports.manageRetrieveAff = { |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
55 type: 'get', |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
56 child: 'pubsub', |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
57 ns: NS.PUBSUB_OWNER, |
30
b2faacfefb90
Rewrite of the module manager; fix of some modules; fix of the directory backend.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
24
diff
changeset
|
58 child2: 'affiliations', |
24
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
59 func: function(response, stanza, request, to) { |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
60 if (!config.enabled('modify-affiliations')) |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
61 return makeError(response, errors.owner.manage_affiliations.not_supported.n); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
62 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
63 var nodeID = request.getAttribute('node'); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
64 if (!nodeID || nodeID == '') |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
65 return makeError(response, errors.nodeid_required.n); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
66 if (!storage.existsNode(nodeID)) |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
67 return makeError(response, errors.node_does_not_exist.n); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
68 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
69 var affils = storage.getAffiliationsFromNodeID(nodeID); |
47
0d3f18bb1d36
Remove usage of fdsq.js in modules.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
43
diff
changeset
|
70 var affil = affils[JID.toBare(to)]; |
24
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
71 if (affil != 'super-owner' && affil != 'owner') |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
72 return makeError(response, errors.owner.manage_affiliations.retrieve_list.entity_is_not_an_owner.n); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
73 |
41
bc717575e66a
Much better handling of modules.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
35
diff
changeset
|
74 response.c('pubsub', {xmlns: NS.PUBSUB_OWNER}) |
bc717575e66a
Much better handling of modules.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
35
diff
changeset
|
75 .c('affiliations', {node: nodeID}); |
24
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
76 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
77 for (var jid in affils) |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
78 response.c('affiliation', {jid: jid, affiliation: affils[jid]}).up(); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
79 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
80 return response; |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
81 } |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
82 } |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
83 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
84 // SECTION 8.8.2: Modify Subscriptions |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
85 exports.modifySub = { |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
86 type: 'set', |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
87 child: 'pubsub', |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
88 ns: NS.PUBSUB_OWNER, |
30
b2faacfefb90
Rewrite of the module manager; fix of some modules; fix of the directory backend.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
24
diff
changeset
|
89 child2: 'subscriptions', |
24
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
90 func: function(response, stanza, request, to) { |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
91 if (!config.enabled('manage-subscriptions')) |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
92 return makeError(response, errors.owner.manage_subscriptions.not_supported.n); //XXX |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
93 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
94 var nodeID = request.getAttribute('node'); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
95 if (!nodeID) |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
96 return makeError(response, errors.nodeid_required.n); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
97 if (!storage.existsNode(nodeID)) |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
98 return makeError(response, errors.node_does_not_exist.n); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
99 |
47
0d3f18bb1d36
Remove usage of fdsq.js in modules.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
43
diff
changeset
|
100 var affil = storage.getAffiliation(JID.toBare(to), nodeID); |
24
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
101 if (affil != 'super-owner' && affil != 'owner') |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
102 return makeError(response, errors.forbidden.n); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
103 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
104 var e = false; |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
105 var tags2 = []; |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
106 for (i in request.tags) { |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
107 var tag = request.tags[i]; |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
108 var jid = tag.getAttribute('jid'); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
109 var sub = tag.getAttribute('subscription'); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
110 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
111 if (sub == 'none' || sub == 'pending' || sub == 'subscribed' || sub == 'unconfigured') { |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
112 var set = storage.subscribe(nodeID, jid, sub); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
113 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
114 if (typeof set == 'number') { |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
115 e = true; |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
116 tags2.push(tag); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
117 } else { |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
118 // SECTION 8.8.4 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
119 notifs.send(jid, 'subscription', nodeID, {jid: jid, subscription: sub}); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
120 } |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
121 } else { |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
122 e = true; |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
123 tags2.push(tag); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
124 } |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
125 } |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
126 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
127 request.tags = tags2; |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
128 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
129 if (e) |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
130 return makeError(response, errors.owner.manage_subscriptions.modify.multiple_simultaneous_modifications.n, pubsub); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
131 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
132 return response; |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
133 } |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
134 } |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
135 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
136 // SECTION 8.9.2: Modify Affiliation |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
137 exports.modifyAff = { |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
138 type: 'set', |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
139 child: 'pubsub', |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
140 ns: NS.PUBSUB_OWNER, |
30
b2faacfefb90
Rewrite of the module manager; fix of some modules; fix of the directory backend.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
24
diff
changeset
|
141 child2: 'affiliations', |
24
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
142 func: function(response, stanza, request, to) { |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
143 if (!config.enabled('modify-affiliations')) |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
144 return makeError(response, errors.owner.manage_affiliations.not_supported.n); //XXX |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
145 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
146 var nodeID = request.getAttribute('node'); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
147 if (!nodeID) |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
148 return makeError(response, errors.nodeid_required.n); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
149 if (!storage.existsNode(nodeID)) |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
150 return makeError(response, errors.node_does_not_exist.n); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
151 |
47
0d3f18bb1d36
Remove usage of fdsq.js in modules.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
43
diff
changeset
|
152 var affil = storage.getAffiliation(JID.toBare(to), nodeID); |
24
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
153 if (affil != 'super-owner' && affil != 'owner') |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
154 return makeError(response, errors.forbidden.n); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
155 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
156 var e = false; |
54
c2c9c06d6e9d
Fix problems with unneeded text nodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
48
diff
changeset
|
157 for (var i in request.tags) { |
c2c9c06d6e9d
Fix problems with unneeded text nodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
48
diff
changeset
|
158 var jid = request.tags[i].getAttribute('jid'); |
c2c9c06d6e9d
Fix problems with unneeded text nodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
48
diff
changeset
|
159 var affiliation = request.tags[i].getAttribute('affiliation'); |
24
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
160 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
161 var set = storage.setAffiliation(nodeID, jid, affiliation); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
162 if (typeof set == 'number') |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
163 e = true; |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
164 else { |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
165 // SECTION 8.9.4 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
166 notifs.send(jid, 'affiliations', nodeID, {jid: jid, affiliation: affiliation}); |
54
c2c9c06d6e9d
Fix problems with unneeded text nodes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
48
diff
changeset
|
167 request.tags.splice(i, 1); |
24
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
168 } |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
169 } |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
170 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
171 if (e) |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
172 return makeError(response, errors.owner.manage_affiliations.modify.multiple_simultaneous_modifications.n, pubsub); |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
173 |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
174 return response; |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
175 } |
b80ab94da447
Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
176 } |