comparison modules/mod_publish.js @ 47:0d3f18bb1d36

Remove usage of fdsq.js in modules.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 10 Mar 2011 16:13:49 +0100
parents 023f767662d3
children c979c4d0932b
comparison
equal deleted inserted replaced
46:3126f8d6a5e3 47:0d3f18bb1d36
39 autocreate = true; 39 autocreate = true;
40 else 40 else
41 return makeError(response, errors.node_does_not_exist.n); 41 return makeError(response, errors.node_does_not_exist.n);
42 } 42 }
43 43
44 var affil = storage.getAffiliation(toBareJID(to), nodeID); 44 var affil = storage.getAffiliation(JID.toBare(to), nodeID);
45 if (typeof affil == 'number' && affil != errors.node_does_not_exist.n) 45 if (typeof affil == 'number' && affil != errors.node_does_not_exist.n)
46 return makeError(response, affil); 46 return makeError(response, affil);
47 if (!autocreate && affil != 'super-owner' && affil != 'owner' && affil != 'publisher' && affil != 'publish-only') 47 if (!autocreate && affil != 'super-owner' && affil != 'owner' && affil != 'publisher' && affil != 'publish-only')
48 return makeError(response, errors.forbidden.n); 48 return makeError(response, errors.forbidden.n);
49 49
50 var item = request.getChild('item'); 50 var item = request.getChild('item');
51 var itemID = item.getAttribute('id'); 51 var itemID = item.getAttribute('id');
52 if (!config.enabled('item-ids') && itemID) 52 if (!config.enabled('item-ids') && itemID)
53 return makeError(response, errors.itemid_required.n); 53 return makeError(response, errors.itemid_required.n);
54 itemID = itemID? itemID: fdsq.makeRandomId(); 54 itemID = itemID? itemID: makeRandomId();
55 55
56 if (item.tags.length != 1) 56 if (item.tags.length != 1)
57 return makeError(response, errors.pub.publish.bad_payload.n); 57 return makeError(response, errors.pub.publish.bad_payload.n);
58 58
59 var conf = storage.getConfiguration(nodeID); 59 var conf = storage.getConfiguration(nodeID);
75 } 75 }
76 76
77 if (autocreate) { 77 if (autocreate) {
78 if (!form) 78 if (!form)
79 form = {}; 79 form = {};
80 form['pubsub#creator'] = toBareJID(to); 80 form['pubsub#creator'] = JID.toBare(to);
81 81
82 var r = storage.createNode(nodeID, form); 82 var r = storage.createNode(nodeID, form);
83 if (typeof r == 'number') 83 if (typeof r == 'number')
84 return makeError(response, r); 84 return makeError(response, r);
85 } 85 }
127 127
128 var itemID = item.getAttribute('id') 128 var itemID = item.getAttribute('id')
129 if (!itemID || itemID == '') 129 if (!itemID || itemID == '')
130 return makeError(response, errors.pub.retract.item_or_itemid_required.n); 130 return makeError(response, errors.pub.retract.item_or_itemid_required.n);
131 131
132 var affil = storage.getAffiliation(toBareJID(to), nodeID); 132 var affil = storage.getAffiliation(JID.toBare(to), nodeID);
133 if (affil != 'super-owner' && affil != 'owner' && affil != 'publish-only') 133 if (affil != 'super-owner' && affil != 'owner' && affil != 'publish-only')
134 return makeError(response, errors.forbidden.n); 134 return makeError(response, errors.forbidden.n);
135 135
136 var subscribers = storage.deleteItem(nodeID, itemID); 136 var subscribers = storage.deleteItem(nodeID, itemID);
137 if (typeof subscribers == 'number') 137 if (typeof subscribers == 'number')