comparison modules/mod_publish.js @ 33:62cbb1c49bc5

Fix publish; add owner metadata field; add HTTP module and Atom HTTP module.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 05 Nov 2010 14:01:45 +0100
parents b2faacfefb90
children dcf1f09f8cee
comparison
equal deleted inserted replaced
32:8735fc6f6f53 33:62cbb1c49bc5
1 var config = require('../configuration'); 1 var config = require('../configuration');
2 var storage = require('../storage'); 2 var storage = require('../storage');
3 var notifs = require('../notifs');
3 var toBareJID = require('../util').toBareJID; 4 var toBareJID = require('../util').toBareJID;
4 var NS = require('../namespaces'); 5 var NS = require('../namespaces');
5 6
6 // SECTION 7.1: Publish an Item to a Node 7 // SECTION 7.1: Publish an Item to a Node
7 exports.retrieveSub = { 8 exports.publish = {
8 type: 'set', 9 type: 'set',
9 child: 'pubsub', 10 child: 'pubsub',
10 ns: NS.PUBSUB, 11 ns: NS.PUBSUB,
11 child2: 'publish', 12 child2: 'publish',
12 func: function(response, stanza, request, to) { 13 func: function(response, stanza, request, to) {
39 40
40 if (item.tags.length != 1) 41 if (item.tags.length != 1)
41 return makeError(response, errors.pub.publish.bad_payload.n); 42 return makeError(response, errors.pub.publish.bad_payload.n);
42 43
43 var conf = storage.getConfiguration(nodeID); 44 var conf = storage.getConfiguration(nodeID);
44 var publishOptions = pubsub.getChild('publish-options'); 45 /*var publishOptions = pubsub.getChild('publish-options');
45 if (publishOptions && config.enabled('publish-options')) { 46 if (publishOptions && config.enabled('publish-options')) {
46 var x = publishOptions.getChild('x', 'jabber:x:data'); 47 var x = publishOptions.getChild('x', 'jabber:x:data');
47 if (!x || x.getAttribute('type') != 'submit') 48 if (!x || x.getAttribute('type') != 'submit')
48 return makeError(response, errors.bad_request.n); 49 return makeError(response, errors.bad_request.n);
49 50
50 var form = forms.parse(x, true); 51 var form = forms.parse(x, true);
51 if (form.access_model != conf['pubsub#access_model'] && !autocreate) 52 if (form.access_model != conf['pubsub#access_model'] && !autocreate)
52 return makeError(response, errors.pub.configuration.precondition.n); 53 return makeError(response, errors.pub.configuration.precondition.n);
53 } 54 }*/
54 55
55 if (!config.enabled('persistent-items')) { 56 if (!config.enabled('persistent-items')) {
56 var notifs = storage.purgeNode(nodeID); 57 var notifications = storage.purgeNode(nodeID);
57 if (typeof notifs == 'number') 58 if (typeof notifications == 'number')
58 return makeError(response, r); 59 return makeError(response, r);
59 } 60 }
60 61
61 if (autocreate) { 62 if (autocreate) {
62 if (!form) 63 if (!form)
88 return response; 89 return response;
89 } 90 }
90 } 91 }
91 92
92 // SECTION 7.2: Delete an Item from a Node 93 // SECTION 7.2: Delete an Item from a Node
93 exports.retrieveSub = { 94 exports.retract = {
94 type: 'set', 95 type: 'set',
95 child: 'pubsub', 96 child: 'pubsub',
96 ns: NS.PUBSUB, 97 ns: NS.PUBSUB,
97 child2: 'retract', 98 child2: 'retract',
98 func: function(response, stanza, request, to) { 99 func: function(response, stanza, request, to) {