Comparison

mod_muc_require_tos/mod_muc_require_tos.lua @ 4693:59f53cf66573

mod_muc_require_tos: Generate a message id instead of hardcoding "foo"
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 16 Sep 2021 22:57:52 +0200
parent 4692:37232302dfb9
comparison
equal deleted inserted replaced
4692:37232302dfb9 4693:59f53cf66573
1 local jid = require "util.jid"; 1 local jid = require "util.jid";
2 local id = require "util.id";
2 local st = require "util.stanza"; 3 local st = require "util.stanza";
3 4
4 local quick_response_ns = "urn:xmpp:tmp:quick-response"; 5 local quick_response_ns = "urn:xmpp:tmp:quick-response";
5 local welcome_message = module:get_option_string("tos_welcome_message"); 6 local welcome_message = module:get_option_string("tos_welcome_message");
6 local yes_message = module:get_option_string("tos_yes_message"); 7 local yes_message = module:get_option_string("tos_yes_message");
15 if occupant.role == "visitor" then 16 if occupant.role == "visitor" then
16 local message = st.message({ 17 local message = st.message({
17 type = "groupchat", 18 type = "groupchat",
18 to = occupant.nick, 19 to = occupant.nick,
19 from = room.jid, 20 from = room.jid,
20 id = "foo", 21 id = id.medium(),
21 ["xml:lang"] = "en", 22 ["xml:lang"] = "en",
22 }, welcome_message) 23 }, welcome_message)
23 :tag("response", { xmlns = quick_response_ns, value = "yes", label = "I accept." }):up() 24 :tag("response", { xmlns = quick_response_ns, value = "yes", label = "I accept." }):up()
24 :tag("response", { xmlns = quick_response_ns, value = "no", label = "I decline." }):up(); 25 :tag("response", { xmlns = quick_response_ns, value = "no", label = "I decline." }):up();
25 origin.send(message); 26 origin.send(message);