Developing with PubSub
General
To interface with mod_pubsub the following snippet can be used to get the pubsub service object:
local mod_pubsub = module:depends"pubsub"
local pubsub_service = mod_pubsub.get_service();
See util.pubsub
documentation for details about the API of the pubsub service
object.
Textual notifications
mod_pubsub can produce plain text forms of notifications if something knows how to produce this. Receiving this requires that the subscriber opts in.
An example1 producing plain text versions of Atom feed entries:
:hook("pubsub-summary/http://www.w3.org/2005/Atom", function (event)
modulelocal payload = event.payload;
local title = payload:get_child_text("title");
local summary = payload:get_child_text("summary");
if not summary and title then
local author = payload:find("author/name#");
= title;
summary if author then
= author .. " posted " .. summary;
summary end
end
return summary;
end);
actually part of mod_pubsub↩︎