Changing defaults MUC affiliation (#385):

* video/channel owner is MUC owner
* the bot is MUC owner
* the bot is admin on the MUC component
* Peertube moderators/admins have no more special access (by default)
* migration script to update all existing rooms
This commit is contained in:
John Livingston
2024-05-17 11:47:37 +02:00
parent ebcbe8227b
commit 5745e8c8a3
6 changed files with 166 additions and 27 deletions

View File

@ -1,5 +1,6 @@
local json = require "util.json";
local jid_split = require"util.jid".split;
local jid_prep = require"util.jid".prep;
local array = require "util.array";
local st = require "util.stanza";
@ -89,6 +90,30 @@ local function update_room(event)
must104 = true;
end
end
if type(config.removeAffiliationsFor) == "table" then
-- array of jids
for _, jid in ipairs(config.removeAffiliationsFor) do
room:set_affiliation(true, jid, "none");
end
end
if type(config.addAffiliations) == "table" then
-- map of jid:affiliation
for user_jid, aff in pairs(config.addAffiliations) do
if type(user_jid) == "string" and type(aff) == "string" then
local prepped_jid = jid_prep(user_jid);
if prepped_jid then
local ok, err = room:set_affiliation(true, prepped_jid, aff);
if not ok then
module:log("error", "Could not set affiliation in %s: %s", room.jid, err);
-- FIXME: fail?
end
else
module:log("error", "Invalid JID: %q", aff.jid);
-- FIXME: fail?
end
end
end
end
if must104 then
-- we must broadcast a status 104 message, so that clients can update room info