Mercurial > psgxs
comparison modules/mod_owner.js @ 30:b2faacfefb90
Rewrite of the module manager; fix of some modules; fix of the directory backend.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Thu, 04 Nov 2010 17:50:52 +0100 |
parents | b80ab94da447 |
children | 8735fc6f6f53 |
comparison
equal
deleted
inserted
replaced
29:e007a6364bf0 | 30:b2faacfefb90 |
---|---|
6 var makeError = errors.makeError; | 6 var makeError = errors.makeError; |
7 var toBareJID = require('../util').toBareJID; | 7 var toBareJID = require('../util').toBareJID; |
8 var NS = require('../namespaces'); | 8 var NS = require('../namespaces'); |
9 | 9 |
10 // SECTION 8.1: Create a Node | 10 // SECTION 8.1: Create a Node |
11 exports.getConfigure = { | 11 exports.create = { |
12 type: 'set', | 12 type: 'set', |
13 child: 'pubsub', | 13 child: 'pubsub', |
14 ns: NS.PUBSUB, | 14 ns: NS.PUBSUB, |
15 pschild: 'create', | 15 child2: 'create', |
16 func: function(response, stanza, request, to) { | 16 func: function(response, stanza, request, to) { |
17 if (!config.enabled('create-nodes')) | 17 if (!config.enabled('create-nodes')) |
18 return makeError(response, errors.owner.create.node_creation_not_supported.n); | 18 return makeError(response, errors.owner.create.node_creation_not_supported.n); |
19 | 19 |
20 var instant = false; | 20 var instant = false; |
43 right = true; | 43 right = true; |
44 | 44 |
45 if (!right) | 45 if (!right) |
46 return makeError(response, errors.forbidden.n); | 46 return makeError(response, errors.forbidden.n); |
47 | 47 |
48 var r = storage.createNode(nodeID); | 48 conf = {}; |
49 conf['pubsub#creator'] = bare; | |
50 | |
51 var r = storage.createNode(nodeID, conf); | |
49 if (typeof r == 'number') | 52 if (typeof r == 'number') |
50 return makeError(response, r); | 53 return makeError(response, r); |
51 | 54 |
52 if (instant) | 55 if (instant) |
53 response.c('pubsub', {xmlns: NS.PUBSUB}) | 56 response.c('pubsub', {xmlns: NS.PUBSUB}) |
60 // SECTION 8.4: Delete a Node | 63 // SECTION 8.4: Delete a Node |
61 exports['delete'] = { | 64 exports['delete'] = { |
62 type: 'set', | 65 type: 'set', |
63 child: 'pubsub', | 66 child: 'pubsub', |
64 ns: NS.PUBSUB_OWNER, | 67 ns: NS.PUBSUB_OWNER, |
65 pschild: 'delete', | 68 child2: 'delete', |
66 func: function(response, stanza, request, to) { | 69 func: function(response, stanza, request, to) { |
67 if (!config.enabled('delete-nodes')) | 70 if (!config.enabled('delete-nodes')) |
68 return makeError(response, errors.feature_not_implemented.n); //XXX | 71 return makeError(response, errors.feature_not_implemented.n); //XXX |
69 | 72 |
70 var nodeID = request.getAttribute('node'); | 73 var nodeID = request.getAttribute('node'); |
75 | 78 |
76 var affil = storage.getAffiliation(toBareJID(to), nodeID); | 79 var affil = storage.getAffiliation(toBareJID(to), nodeID); |
77 if (affil != 'super-owner' && affil != 'owner') | 80 if (affil != 'super-owner' && affil != 'owner') |
78 return makeError(response, errors.forbidden.n); | 81 return makeError(response, errors.forbidden.n); |
79 | 82 |
80 var notifs = storage.deleteNode(nodeID); | 83 var notifications = storage.deleteNode(nodeID); |
81 if (typeof notifs == 'number') | 84 if (typeof notifications == 'number') |
82 return makeError(response, r); | 85 return makeError(response, r); |
83 | 86 |
84 notifs.send(notifs, 'delete', nodeID); | 87 notifs.send(notifications, 'delete', nodeID); |
85 | 88 |
86 return response; | 89 return response; |
87 } | 90 } |
88 } | 91 } |
89 | 92 |
90 // SECTION 8.5: Purge All Node Items | 93 // SECTION 8.5: Purge All Node Items |
91 exports.purge = { | 94 exports.purge = { |
92 type: 'set', | 95 type: 'set', |
93 child: 'pubsub', | 96 child: 'pubsub', |
94 ns: NS.PUBSUB_OWNER, | 97 ns: NS.PUBSUB_OWNER, |
95 pschild: 'purge', | 98 child2: 'purge', |
96 func: function(response, stanza, request, to) { | 99 func: function(response, stanza, request, to) { |
97 if (!config.enabled('purge-nodes')) | 100 if (!config.enabled('purge-nodes')) |
98 return makeError(response, errors.owner.purge.node_purging_not_supported.n); //XXX | 101 return makeError(response, errors.owner.purge.node_purging_not_supported.n); //XXX |
99 | 102 |
100 var nodeID = request.getAttribute('node'); | 103 var nodeID = request.getAttribute('node'); |
108 return makeError(response, errors.forbidden.n); | 111 return makeError(response, errors.forbidden.n); |
109 | 112 |
110 if (!config.enabled('persistent-items')) //FIXME: autre condition, supporté par le node | 113 if (!config.enabled('persistent-items')) //FIXME: autre condition, supporté par le node |
111 return makeError(response, errors.owner.purge.node_does_not_persist_items.n); | 114 return makeError(response, errors.owner.purge.node_does_not_persist_items.n); |
112 | 115 |
113 var notifs = storage.purgeNode(nodeID); | 116 var notifications = storage.purgeNode(nodeID); |
114 if (typeof notifs == 'number') | 117 if (typeof notifications == 'number') |
115 return makeError(response, r); | 118 return makeError(response, r); |
116 | 119 |
117 notifs.send(notifs, 'purge', nodeID); | 120 notifs.send(notifications, 'purge', nodeID); |
118 | 121 |
119 return response; | 122 return response; |
120 } | 123 } |
121 } | 124 } |