Software /
code /
verse
Diff
plugins/pubsub.lua @ 170:cb03e8ae2e30
Merge with Zash
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 15 Dec 2010 15:03:56 +0000 |
parent | 165:8c67ea868c06 |
child | 193:fa6e1e65cb3c |
line wrap: on
line diff
--- a/plugins/pubsub.lua Wed Dec 15 15:03:46 2010 +0000 +++ b/plugins/pubsub.lua Wed Dec 15 15:03:56 2010 +0000 @@ -9,6 +9,22 @@ function verse.plugins.pubsub(stream) stream.pubsub = setmetatable({ stream = stream }, pubsub_mt); + stream:hook("message", function (message) + for pubsub_event in message:matching_tags("event", xmlns_pubsub_event) do + local items = pubsub_event:get_child("items"); + if items then + local node = items.attr.node; + for item in items:matching_tags("item") do + stream:event("pubsub/event", { + from = message.attr.from; + node = node; + item = item; + }); + end + end + end + end); + return true; end function pubsub:subscribe(server, node, jid, callback)