Mercurial > psgxs
comparison storage.js @ 1:c2954a9e5665
Add a super-owner that has power over all nodes; add support for
affiliation changes; support pubsub#creator metadata; change
pubsub#digest_frequency default; and use better default config values.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Mon, 28 Jun 2010 21:55:30 +0200 |
parents | 9ee956af41e3 |
children | d8a98540d749 |
comparison
equal
deleted
inserted
replaced
0:9ee956af41e3 | 1:c2954a9e5665 |
---|---|
292 return 42; //FIXME | 292 return 42; //FIXME |
293 | 293 |
294 var items = storage.existsItem(nodeID, itemID); | 294 var items = storage.existsItem(nodeID, itemID); |
295 if (typeof items == 'number') | 295 if (typeof items == 'number') |
296 return items; | 296 return items; |
297 | |
297 if (items) | 298 if (items) |
298 return items.content; | 299 return items.content; |
300 | |
299 return errors.item_not_found; | 301 return errors.item_not_found; |
300 }; | 302 }; |
301 | 303 |
302 storage.getSubscription = function(jid, nodeID) { | 304 storage.getSubscription = function(jid, nodeID) { |
303 var subs = {}; | 305 var subs = {}; |
386 if (typeof node == 'number') | 388 if (typeof node == 'number') |
387 return node; | 389 return node; |
388 } else | 390 } else |
389 node = nodeID; | 391 node = nodeID; |
390 | 392 |
393 for (var affil in config.owner) | |
394 if (typeof affil == 'string' && node.owner[affil] == jid) | |
395 return 'super-owner'; | |
391 for (var affil in node.owner) | 396 for (var affil in node.owner) |
392 if (typeof affil == 'string' && node.owner[affil] == jid) | 397 if (typeof affil == 'string' && node.owner[affil] == jid) |
393 return 'owner'; | 398 return 'owner'; |
394 if (config.enabled('publisher-affiliation')) | 399 if (config.enabled('publisher-affiliation')) |
395 for (var affil in node.publisher) | 400 for (var affil in node.publisher) |
406 return 'none'; | 411 return 'none'; |
407 }; | 412 }; |
408 | 413 |
409 storage.getAffiliationsFromJID = function(jid) { | 414 storage.getAffiliationsFromJID = function(jid) { |
410 var affils = {}; | 415 var affils = {}; |
411 for (var node in list) { | 416 for (var nodeID in list) { |
412 var n = list[node]; | 417 var node = list[nodeID]; |
413 for (var affil in n.owner) | 418 for (var affil in config.owner) |
414 if (typeof affil == 'string' && n.owner[affil] == jid) { | 419 if (typeof affil == 'string' && config.owner[affil] == jid) { |
415 affils[node] = 'owner'; | 420 affils[nodeID] = 'super-owner'; |
421 break; | |
422 } | |
423 for (var affil in node.owner) | |
424 if (typeof affil == 'string' && node.owner[affil] == jid) { | |
425 affils[nodeID] = 'owner'; | |
416 break; | 426 break; |
417 } | 427 } |
418 if (config.enabled('publisher-affiliation')) | 428 if (config.enabled('publisher-affiliation')) |
419 for (var affil in n.publisher) | 429 for (var affil in node.publisher) |
420 if (typeof affil == 'string' && n.publisher[affil] == jid) { | 430 if (typeof affil == 'string' && node.publisher[affil] == jid) { |
421 affils[node] = 'publisher'; | 431 affils[nodeID] = 'publisher'; |
422 break; | 432 break; |
423 } | 433 } |
424 if (config.enabled('publish-only-affiliation')) | 434 if (config.enabled('publish-only-affiliation')) |
425 for (var affil in n.publishOnly) | 435 for (var affil in node.publishOnly) |
426 if (typeof affil == 'string' && n.publishOnly[affil] == jid) { | 436 if (typeof affil == 'string' && node.publishOnly[affil] == jid) { |
427 affils[node] = 'publish-only'; | 437 affils[nodeID] = 'publish-only'; |
428 break; | 438 break; |
429 } | 439 } |
430 if (config.enabled('outcast-affiliation')) | 440 if (config.enabled('outcast-affiliation')) |
431 for (var affil in n.outcast) | 441 for (var affil in node.outcast) |
432 if (typeof affil == 'string' && n.outcast[affil] == jid) { | 442 if (typeof affil == 'string' && node.outcast[affil] == jid) { |
433 affils[node] = 'outcast'; | 443 affils[nodeID] = 'outcast'; |
434 break; | 444 break; |
435 } | 445 } |
436 } | 446 } |
437 return affils; | 447 return affils; |
438 }; | 448 }; |
445 return node; | 455 return node; |
446 } else | 456 } else |
447 node = nodeID; | 457 node = nodeID; |
448 | 458 |
449 var affils = {}; | 459 var affils = {}; |
460 for (var jid in config.owner) | |
461 if (typeof jid == 'string') | |
462 affils[config.owner[jid]] = 'super-owner'; | |
450 for (var jid in node.owner) | 463 for (var jid in node.owner) |
451 if (typeof jid == 'string') | 464 if (typeof jid == 'string') |
452 affils[node.owner[jid]] = 'owner'; | 465 affils[node.owner[jid]] = 'owner'; |
453 if (config.enabled('publisher-affiliation')) | 466 if (config.enabled('publisher-affiliation')) |
454 for (var jid in node.publisher) | 467 for (var jid in node.publisher) |