comparison modules/mod_publish_message.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 99bd1d1ac071
comparison
equal deleted inserted replaced
46:3126f8d6a5e3 47:0d3f18bb1d36
24 child: 'body', 24 child: 'body',
25 func: function(response, stanza, request, to, from) { 25 func: function(response, stanza, request, to, from) {
26 if (!config.enabled('publish')) 26 if (!config.enabled('publish'))
27 return makeError(response, errors.pub.publish.item_publication_not_supported.n); 27 return makeError(response, errors.pub.publish.item_publication_not_supported.n);
28 28
29 var nodeID = fdsq.toResource(from); 29 var nodeID = JID.toResource(from);
30 if (!nodeID || nodeID == '') 30 if (!nodeID || nodeID == '')
31 return makeError(response, errors.nodeid_required.n); 31 return makeError(response, errors.nodeid_required.n);
32 32
33 var autocreate = false; 33 var autocreate = false;
34 if (!storage.existsNode(nodeID)) { 34 if (!storage.existsNode(nodeID)) {
36 autocreate = true; 36 autocreate = true;
37 else 37 else
38 return makeError(response, errors.node_does_not_exist.n); 38 return makeError(response, errors.node_does_not_exist.n);
39 } 39 }
40 40
41 var affil = storage.getAffiliation(toBareJID(to), nodeID); 41 var affil = storage.getAffiliation(JID.toBare(to), nodeID);
42 if (typeof affil == 'number' && affil != errors.node_does_not_exist.n) 42 if (typeof affil == 'number' && affil != errors.node_does_not_exist.n)
43 return makeError(response, affil); 43 return makeError(response, affil);
44 if (!autocreate && affil != 'super-owner' && affil != 'owner' && affil != 'publisher' && affil != 'publish-only') 44 if (!autocreate && affil != 'super-owner' && affil != 'owner' && affil != 'publisher' && affil != 'publish-only')
45 return makeError(response, errors.forbidden.n); 45 return makeError(response, errors.forbidden.n);
46 46
47 if (!config.enabled('item-ids')) 47 if (!config.enabled('item-ids'))
48 return makeError(response, errors.itemid_required.n); 48 return makeError(response, errors.itemid_required.n);
49 var itemID = fdsq.makeRandomId(); 49 var itemID = makeRandomId();
50 50
51 var now = new Date(); 51 var now = new Date();
52 52
53 var item = xmpp.stanza('item', {xmlns: NS.PUBSUB, id: itemID}); 53 var item = xmpp.stanza('item', {xmlns: NS.PUBSUB, id: itemID});
54 item.c('entry', {xmlns: NS.ATOM}); 54 item.c('entry', {xmlns: NS.ATOM});
66 } 66 }
67 67
68 if (autocreate) { 68 if (autocreate) {
69 if (!form) 69 if (!form)
70 form = {}; 70 form = {};
71 form['pubsub#creator'] = toBareJID(to); 71 form['pubsub#creator'] = JID.toBare(to);
72 72
73 var r = storage.createNode(nodeID, form); 73 var r = storage.createNode(nodeID, form);
74 if (typeof r == 'number') 74 if (typeof r == 'number')
75 return makeError(response, r); 75 return makeError(response, r);
76 } 76 }