Software /
code /
prosody
File
plugins/muc/presence_broadcast.lib.lua @ 10399:270cb2821566
mod_ping: Remove ad-hoc command
17:27:40 <Ge0rG> Zash: the Ping thing is absolutely worthless
17:27:55 <Zash> The command provided by mod_ping?
17:27:59 <pep.> To own server?
17:28:14 <Ge0rG> the Ping command in mod_admin_web, whatever it maps to
17:28:29 <Ge0rG> > Pong
> 2019-11-07T16:28:16Z
What am I supposed to do with that result?
17:28:29 <Zash> Yeah, mod_ping provides that
17:28:41 <Ge0rG> Is it a ping to my own server? Where's the RTT?
17:28:48 <Zash> Dunno if it's useful for more than verifying that the adhoc command system works
17:29:02 <Ge0rG> (it lags, but there is no indication of how much)
17:29:14 <Zash> It can't really test that itself
17:29:52 <Zash> Anyone opposed to deleting it?
17:30:42 <Zash> Half the module
17:42:47 <MattJ> Zash, I'm fine with removing it
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 07 Nov 2019 19:23:42 +0100 |
parent | 10353:7b602e13c3b6 |
child | 10516:d3e6941546a8 |
line wrap: on
line source
-- Prosody IM -- Copyright (C) 2008-2010 Matthew Wild -- Copyright (C) 2008-2010 Waqas Hussain -- Copyright (C) 2014 Daurnimator -- -- This project is MIT/X11 licensed. Please see the -- COPYING file in the source package for more information. -- local st = require "util.stanza"; local valid_roles = { "visitor", "participant", "moderator" }; local default_broadcast = { none = true; visitor = true; participant = true; moderator = true; }; local function get_presence_broadcast(room) return room._data.presence_broadcast or default_broadcast; end local function set_presence_broadcast(room, broadcast_roles) broadcast_roles = broadcast_roles or default_broadcast; -- Ensure that unavailable presence is always sent when role changes to none broadcast_roles.none = true; local changed = false; local old_broadcast_roles = get_presence_broadcast(room); for _, role in ipairs(valid_roles) do if old_broadcast_roles[role] ~= broadcast_roles[role] then changed = true; end end if not changed then return false; end room._data.presence_broadcast = broadcast_roles; for _, occupant in room:each_occupant() do local x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user";}); local role = occupant.role or "none"; if broadcast_roles[role] and not old_broadcast_roles[role] then -- Presence broadcast is now enabled, so announce existing user room:publicise_occupant_status(occupant, x); elseif old_broadcast_roles[role] and not broadcast_roles[role] then -- Presence broadcast is now disabled, so mark existing user as unavailable room:publicise_occupant_status(occupant, x, nil, nil, nil, nil, true); end end return true; end module:hook("muc-config-form", function(event) local values = {}; for role, value in pairs(get_presence_broadcast(event.room)) do if value then values[#values + 1] = role; end end table.insert(event.form, { name = "muc#roomconfig_presencebroadcast"; type = "list-multi"; label = "Roles for which Presence is Broadcasted"; value = values; options = valid_roles; }); end, 70-7); module:hook("muc-config-submitted/muc#roomconfig_presencebroadcast", function(event) local broadcast_roles = {}; for _, role in ipairs(event.value) do broadcast_roles[role] = true; end if set_presence_broadcast(event.room, broadcast_roles) then event.status_codes["104"] = true; end end); return { get = get_presence_broadcast; set = set_presence_broadcast; };