Mercurial > prosody-hg
comparison plugins/mod_pep_plus.lua @ 8335:9db72349095f
mod_pep_plus: Use dispatch function from pubsub.lib
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 18 Oct 2017 07:47:00 +0200 |
| parents | 2abbb01cd756 |
| children | 4fce6bc0719f |
comparison
equal
deleted
inserted
replaced
| 8334:036e46d12b78 | 8335:9db72349095f |
|---|---|
| 215 return service; | 215 return service; |
| 216 end | 216 end |
| 217 | 217 |
| 218 function handle_pubsub_iq(event) | 218 function handle_pubsub_iq(event) |
| 219 local origin, stanza = event.origin, event.stanza; | 219 local origin, stanza = event.origin, event.stanza; |
| 220 local pubsub_tag = stanza.tags[1]; | |
| 221 local action = pubsub_tag.tags[1]; | |
| 222 if not action then | |
| 223 return origin.send(st.error_reply(stanza, "cancel", "bad-request")); | |
| 224 end | |
| 225 local service_name = origin.username; | 220 local service_name = origin.username; |
| 226 if stanza.attr.to ~= nil then | 221 if stanza.attr.to ~= nil then |
| 227 service_name = jid_split(stanza.attr.to); | 222 service_name = jid_split(stanza.attr.to); |
| 228 end | 223 end |
| 229 local service = get_pep_service(service_name); | 224 local service = get_pep_service(service_name); |
| 230 local handler = handlers[stanza.attr.type.."_"..action.name]; | 225 |
| 231 if handler then | 226 return lib_pubsub.handle_pubsub_iq(event, service) |
| 232 handler(origin, stanza, action, service); | |
| 233 return true; | |
| 234 end | |
| 235 end | 227 end |
| 236 | 228 |
| 237 module:hook("iq/bare/"..xmlns_pubsub..":pubsub", handle_pubsub_iq); | 229 module:hook("iq/bare/"..xmlns_pubsub..":pubsub", handle_pubsub_iq); |
| 238 module:hook("iq/bare/"..xmlns_pubsub_owner..":pubsub", handle_pubsub_iq); | 230 module:hook("iq/bare/"..xmlns_pubsub_owner..":pubsub", handle_pubsub_iq); |
| 239 | 231 |
