annotate modules/mod_publish.js @ 43:023f767662d3

Fix compatibility with strict mode of node 0.4 and some files without licence header.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 01 Mar 2011 11:58:15 +0100
parents bc717575e66a
children 0d3f18bb1d36
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 7.1: Publish an Item to a Node
33
62cbb1c49bc5 Fix publish; add owner metadata field; add HTTP module and Atom HTTP module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 30
diff changeset
23 exports.publish = {
24
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
24 type: 'set',
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,
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: 'publish',
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('publish'))
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
30 return makeError(response, errors.pub.publish.item_publication_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
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
36 var autocreate = false;
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
37 if (!storage.existsNode(nodeID)) {
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
38 if (config.enabled('auto-create'))
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
39 autocreate = true;
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
40 else
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
41 return makeError(response, errors.node_does_not_exist.n);
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
42 }
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
43
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
44 var affil = storage.getAffiliation(toBareJID(to), nodeID);
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
45 if (typeof affil == 'number' && affil != errors.node_does_not_exist.n)
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
46 return makeError(response, affil);
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
47 if (!autocreate && affil != 'super-owner' && affil != 'owner' && affil != 'publisher' && affil != 'publish-only')
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
48 return makeError(response, errors.forbidden.n);
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
49
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
50 var item = request.getChild('item');
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
51 var itemID = item.getAttribute('id');
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
52 if (!config.enabled('item-ids') && itemID)
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
53 return makeError(response, errors.itemid_required.n);
35
6697f394301f Replace util with fdsq to work around a stupid bug.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 34
diff changeset
54 itemID = itemID? itemID: fdsq.makeRandomId();
24
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
55
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
56 if (item.tags.length != 1)
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
57 return makeError(response, errors.pub.publish.bad_payload.n);
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
58
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
59 var conf = storage.getConfiguration(nodeID);
33
62cbb1c49bc5 Fix publish; add owner metadata field; add HTTP module and Atom HTTP module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 30
diff changeset
60 /*var publishOptions = pubsub.getChild('publish-options');
24
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
61 if (publishOptions && config.enabled('publish-options')) {
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
62 var x = publishOptions.getChild('x', 'jabber:x:data');
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
63 if (!x || x.getAttribute('type') != 'submit')
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
64 return makeError(response, errors.bad_request.n);
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
65
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
66 var form = forms.parse(x, true);
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
67 if (form.access_model != conf['pubsub#access_model'] && !autocreate)
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
68 return makeError(response, errors.pub.configuration.precondition.n);
33
62cbb1c49bc5 Fix publish; add owner metadata field; add HTTP module and Atom HTTP module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 30
diff changeset
69 }*/
24
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
70
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
71 if (!config.enabled('persistent-items')) {
33
62cbb1c49bc5 Fix publish; add owner metadata field; add HTTP module and Atom HTTP module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 30
diff changeset
72 var notifications = storage.purgeNode(nodeID);
62cbb1c49bc5 Fix publish; add owner metadata field; add HTTP module and Atom HTTP module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 30
diff changeset
73 if (typeof notifications == 'number')
24
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
74 return makeError(response, r);
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
75 }
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 if (autocreate) {
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
78 if (!form)
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
79 form = {};
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
80 form['pubsub#creator'] = toBareJID(to);
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 var r = storage.createNode(nodeID, form);
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
83 if (typeof r == 'number')
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
84 return makeError(response, r);
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
85 }
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
86
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
87 var content = item.getChild();
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
88
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
89 subscribers = storage.setItem(nodeID, itemID, content);
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
90 if (typeof subscribers == 'number')
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
91 return makeError(response, subscribers);
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
92
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
93 var attrs = {};
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
94 if (content)
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
95 attrs[itemID] = {content: content};
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
96 else
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
97 attrs[itemID] = {};
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
98 notifs.send(subscribers, 'items', nodeID, attrs);
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
99
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
100 response.c('pubsub', {xmlns: NS.PUBSUB})
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
101 .c('publish', {node: nodeID})
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
102 .c('item', {id: itemID});
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 return response;
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
105 }
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
106 }
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
107
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
108 // SECTION 7.2: Delete an Item from a Node
33
62cbb1c49bc5 Fix publish; add owner metadata field; add HTTP module and Atom HTTP module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 30
diff changeset
109 exports.retract = {
24
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
110 type: 'set',
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
111 child: 'pubsub',
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
112 ns: NS.PUBSUB,
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
113 child2: 'retract',
24
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
114 func: function(response, stanza, request, to) {
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
115 if (!config.enabled('retract-items'))
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
116 return makeError(response, errors.pub.retract.item_deletion_not_supported.n);
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
117
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
118 var nodeID = request.getAttribute('node');
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
119 if (!nodeID || nodeID == '')
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
120 return makeError(response, errors.nodeid_required.n);
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
121 if (!storage.existsNode(nodeID))
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
122 return makeError(response, errors.node_does_not_exist.n);
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
123
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
124 var item = request.getChild('item');
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
125 if (!item)
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
126 return makeError(response, errors.pub.retract.item_or_itemid_required.n);
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
127
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
128 var itemID = item.getAttribute('id')
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
129 if (!itemID || itemID == '')
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
130 return makeError(response, errors.pub.retract.item_or_itemid_required.n);
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 var affil = storage.getAffiliation(toBareJID(to), nodeID);
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
133 if (affil != 'super-owner' && affil != 'owner' && affil != 'publish-only')
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
134 return makeError(response, errors.forbidden.n);
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 var subscribers = storage.deleteItem(nodeID, itemID);
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
137 if (typeof subscribers == 'number')
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
138 return makeError(response, subscribers);
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
139
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
140 var attrs = {};
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
141 attrs[itemID] = {};
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
142 notifs.send(subscribers, 'items', nodeID, attrs, 'retract')
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
143
b80ab94da447 Add new modules files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
144 return response;
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 }