Software /
code /
prosody
Comparison
plugins/mod_pubsub/pubsub.lib.lua @ 12636:e8934ce6ea0f
util.stanza: Add method for extracting a single attribute value
Sometimes you only care about a single attribute, but the child tag
itself may be optional, leading to needing `tag and tag.attr.foo` or
`stanza:find("tag@foo")`.
The `:find()` method is fairly complex, so avoiding it for this kind of
simpler use case is a win.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 17 Aug 2022 19:04:30 +0200 |
parent | 12589:39ae08180c81 |
child | 12960:31b22cc221b5 |
comparison
equal
deleted
inserted
replaced
12635:f928cb5c5d04 | 12636:e8934ce6ea0f |
---|---|
676 end | 676 end |
677 | 677 |
678 function handlers.set_retract(origin, stanza, retract, service) | 678 function handlers.set_retract(origin, stanza, retract, service) |
679 local node, notify = retract.attr.node, retract.attr.notify; | 679 local node, notify = retract.attr.node, retract.attr.notify; |
680 notify = (notify == "1") or (notify == "true"); | 680 notify = (notify == "1") or (notify == "true"); |
681 local item = retract:get_child("item"); | 681 local id = retract:get_child_attr("item", nil, "id"); |
682 local id = item and item.attr.id | |
683 if not (node and id) then | 682 if not (node and id) then |
684 origin.send(pubsub_error_reply(stanza, node and "item-not-found" or "nodeid-required")); | 683 origin.send(pubsub_error_reply(stanza, node and "item-not-found" or "nodeid-required")); |
685 return true; | 684 return true; |
686 end | 685 end |
687 local reply, notifier; | 686 local reply, notifier; |