Software /
code /
prosody-modules
File
mod_muc_require_tos/mod_muc_require_tos.lua @ 5571:ca3c2d11823c
mod_pubsub_feeds: Track latest timestamp seen in feeds instead of last poll
This should ensure that an entry that has a publish timestmap after the
previously oldest post, but before the time of the last poll check, is
published to the node.
Previously if an entry would be skipped if it was published at 13:00
with a timestamp of 12:30, where the last poll was at 12:45.
For feeds that lack a timestamp, it now looks for the first post that is
not published, assuming that the feed is in reverse chronological order,
then iterates back up from there.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 25 Jun 2023 16:27:55 +0200 |
parent | 4693:59f53cf66573 |
line wrap: on
line source
local jid = require "util.jid"; local id = require "util.id"; local st = require "util.stanza"; local quick_response_ns = "urn:xmpp:tmp:quick-response"; local welcome_message = module:get_option_string("tos_welcome_message"); local yes_message = module:get_option_string("tos_yes_message"); local no_message = module:get_option_string("tos_no_message"); module:hook("muc-occupant-session-new", function(event) local origin = event.origin; local room = event.room; local occupant = event.occupant; local nick = occupant.nick; module:log("debug", "%s joined %s (%s)", nick, room, origin); if occupant.role == "visitor" then local message = st.message({ type = "groupchat", to = occupant.nick, from = room.jid, id = id.medium(), ["xml:lang"] = "en", }, welcome_message) :tag("response", { xmlns = quick_response_ns, value = "yes", label = "I accept." }):up() :tag("response", { xmlns = quick_response_ns, value = "no", label = "I decline." }):up(); origin.send(message); end end, 19); module:hook("muc-occupant-groupchat", function(event) local occupant = event.occupant; if occupant == nil or occupant.role ~= "visitor" then return; end local origin = event.origin; local room = event.room; local stanza = event.stanza; -- Namespace must be nil instead of "jabber:client" here. local body = stanza:get_child_text("body", nil); module:log("debug", "%s replied %s", occupant.nick, body); if body == "yes" then room:set_affiliation(true, occupant.bare_jid, "member", "Agreed to the TOS."); origin.send(st.reply(stanza):body(yes_message, { ["xml:lang"] = "en" })); elseif body == "no" then origin.send(st.reply(stanza):body(no_message, { ["xml:lang"] = "en" })); room:set_role(true, occupant.nick, "none", "Declined the TOS."); end end, 51); -- Priority must be > 50, <forbidden/> is sent at this priority.