Mercurial > prosody-hg
comparison plugins/mod_pubsub/pubsub.lib.lua @ 8334:036e46d12b78
mod_pubsub: Move dispatch function into pubsub.lib
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 18 Oct 2017 07:46:44 +0200 |
| parents | 2abbb01cd756 |
| children | 587305c0ff85 |
comparison
equal
deleted
inserted
replaced
| 8333:2abbb01cd756 | 8334:036e46d12b78 |
|---|---|
| 51 name = "pubsub#persist_items"; | 51 name = "pubsub#persist_items"; |
| 52 label = "Persist items to storage"; | 52 label = "Persist items to storage"; |
| 53 }; | 53 }; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 function _M.handle_pubsub_iq(event, service) | |
| 57 local origin, stanza = event.origin, event.stanza; | |
| 58 local pubsub_tag = stanza.tags[1]; | |
| 59 local action = pubsub_tag.tags[1]; | |
| 60 if not action then | |
| 61 return origin.send(st.error_reply(stanza, "cancel", "bad-request")); | |
| 62 end | |
| 63 local handler = handlers[stanza.attr.type.."_"..action.name]; | |
| 64 if handler then | |
| 65 handler(origin, stanza, action, service); | |
| 66 return true; | |
| 67 end | |
| 68 end | |
| 69 | |
| 56 function handlers.get_items(origin, stanza, items, service) | 70 function handlers.get_items(origin, stanza, items, service) |
| 57 local node = items.attr.node; | 71 local node = items.attr.node; |
| 58 local item = items:get_child("item"); | 72 local item = items:get_child("item"); |
| 59 local item_id = item and item.attr.id; | 73 local item_id = item and item.attr.id; |
| 60 | 74 |
