Mercurial > prosody-modules
changeset 4773:eb63890ae8fc
mod_muc_offline_delivery: Allow the module to be enabled by default for all users
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 16 Nov 2021 15:09:52 +0000 |
parents | 85d4ab318d66 |
children | 1132f2888cd2 |
files | mod_muc_offline_delivery/mod_muc_offline_delivery.lua |
diffstat | 1 files changed, 6 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_muc_offline_delivery/mod_muc_offline_delivery.lua Tue Nov 16 15:08:09 2021 +0000 +++ b/mod_muc_offline_delivery/mod_muc_offline_delivery.lua Tue Nov 16 15:09:52 2021 +0000 @@ -1,15 +1,17 @@ local st = require "util.stanza"; +local default_enable = module:get_option_boolean("muc_offline_delivery_default", false); + module:add_item("muc-registration-field", { name = "offline_delivery"; var = "{http://tigase.org/protocol/muc}offline"; type = "boolean"; label = "Receive messages while not connected to the room"; - value = false; + value = default_enable; }); module:hook("muc-registration-submitted", function (event) - local deliver_offline = event.submitted_data.offline_delivery or nil; + local deliver_offline = event.submitted_data.offline_delivery; event.affiliation_data.offline_delivery = deliver_offline; end); @@ -19,7 +21,8 @@ local room = event.room; for jid, affiliation, data in room:each_affiliation() do --luacheck: ignore 213/affiliation local reserved_nickname = data and data.reserved_nickname; - if reserved_nickname and data.offline_delivery then + local user_setting = data.offline_delivery; + if reserved_nickname and user_setting or (user_setting == nil and default_enable) then local is_absent = not room:get_occupant_by_nick(room.jid.."/"..reserved_nickname); if is_absent then module:log("debug", "Forwarding message to offline member <%s>", jid);