Mercurial > prosody-hg
comparison util/pubsub.lua @ 3796:405231b1cb88
mod_pubsub, util.pubsub: Support node creation
| author | Florian Zeitz <florob@babelmonkeys.de> |
|---|---|
| date | Wed, 01 Dec 2010 23:38:47 +0100 |
| parents | 3603aeb325de |
| children | 77171fd1dc3c |
comparison
equal
deleted
inserted
replaced
| 3795:6bd4305044a8 | 3796:405231b1cb88 |
|---|---|
| 26 if node_obj then | 26 if node_obj then |
| 27 return node_obj.subscribers[jid]; | 27 return node_obj.subscribers[jid]; |
| 28 end | 28 end |
| 29 end | 29 end |
| 30 | 30 |
| 31 function service:create(node, actor) | |
| 32 if not self.nodes[node] then | |
| 33 self.nodes[node] = { name = node, subscribers = {}, config = {}, data = {} }; | |
| 34 return true; | |
| 35 end | |
| 36 return false, "conflict"; | |
| 37 end | |
| 38 | |
| 31 function service:publish(node, actor, id, item) | 39 function service:publish(node, actor, id, item) |
| 32 local node_obj = self.nodes[node]; | 40 local node_obj = self.nodes[node]; |
| 33 if not node_obj then | 41 if not node_obj then |
| 34 node_obj = { name = node, subscribers = {}, config = {}, data = {} }; | 42 node_obj = { name = node, subscribers = {}, config = {}, data = {} }; |
| 35 self.nodes[node] = node_obj; | 43 self.nodes[node] = node_obj; |
