Mercurial > prosody-modules
changeset 300:b81e4f86a231
mod_pubsub_feed: Catch and handle errors when publishing
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 26 Dec 2010 19:05:39 +0100 |
parents | 801066bf5793 |
children | b241c79a0eb7 |
files | mod_pubsub_feed/mod_pubsub_feed.lua |
diffstat | 1 files changed, 18 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_pubsub_feed/mod_pubsub_feed.lua Sun Dec 26 18:59:13 2010 +0100 +++ b/mod_pubsub_feed/mod_pubsub_feed.lua Sun Dec 26 19:05:39 2010 +0100 @@ -73,7 +73,24 @@ local item = st.stanza("item", { id = id }):add_child(entry); module:log("debug", "publishing to %s, id %s", node, id); - modules.pubsub.service:publish(node, actor, id, item) + local ok, err = modules.pubsub.service:publish(node, actor, id, item); + if not ok then + if err == "item-not-found" then -- try again + module:log("debug", "got item-not-found, creating %s and trying again", node); + local ok, err = modules.pubsub.service:create(node, actor); + if not ok then + module:log("error", "could not create node: %s", err); + return; + end + local ok, err = modules.pubsub.service:publish(node, actor, id, item); + if not ok then + module:log("error", "still could not create node: %s", err); + return + end + else + module:log("error", "publish failed: %s", err); + end + end end end end);