comparison psgxs.js @ 22:0f42c9c8085a

Fix configure setting error and handle cancelling of configure.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 23 Oct 2010 02:31:09 +0200
parents e55b31f12f8c
children 5fc4ee90c1bc
comparison
equal deleted inserted replaced
21:e55b31f12f8c 22:0f42c9c8085a
791 // SECTION 8.2.4 791 // SECTION 8.2.4
792 if (pubsub.getChild('configure')) { 792 if (pubsub.getChild('configure')) {
793 if (!config.enabled('config-node')) 793 if (!config.enabled('config-node'))
794 return makeError(response, errors.owner.configure.node_configuration_not_supported.n); 794 return makeError(response, errors.owner.configure.node_configuration_not_supported.n);
795 795
796 var configure = pubsub.getChild('configure');
797
796 var nodeID = configure.getAttribute('node'); 798 var nodeID = configure.getAttribute('node');
797 if (!nodeID) 799 if (!nodeID)
798 return makeError(response, errors.nodeid_required.n); 800 return makeError(response, errors.nodeid_required.n);
799 if (!storage.existsNode(nodeID)) 801 if (!storage.existsNode(nodeID))
800 return makeError(response, errors.node_does_not_exist.n); 802 return makeError(response, errors.node_does_not_exist.n);
802 var affil = storage.getAffiliation(toBareJID(to), nodeID); 804 var affil = storage.getAffiliation(toBareJID(to), nodeID);
803 if (affil != 'super-owner' && affil != 'owner' && affil != 'publish-only') 805 if (affil != 'super-owner' && affil != 'owner' && affil != 'publish-only')
804 return makeError(response, errors.forbidden.n); 806 return makeError(response, errors.forbidden.n);
805 807
806 var x = configure.getChild('x', 'jabber:x:data'); 808 var x = configure.getChild('x', 'jabber:x:data');
807 if (!x || x.getAttribute(type) != 'submit') 809 if (!x)
810 return makeError(response, errors.bad_request.n);
811
812 var type = x.getAttribute('type');
813 if (type == 'cancel') {
814 conn.send(response);
815 return;
816 }
817 if (type != 'submit')
808 return makeError(response, errors.bad_request.n); 818 return makeError(response, errors.bad_request.n);
809 819
810 var form = forms.parse(x, true); 820 var form = forms.parse(x, true);
811 if (typeof form == 'number') 821 if (typeof form == 'number')
812 return makeError(response, form); 822 return makeError(response, form);