Developing with PubSub


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:

module:hook("pubsub-summary/", function (event)
    local 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#");
        summary = title;
        if author then
            summary = author .. " posted " .. summary;
    return summary;

  1. actually part of mod_pubsub↩︎