MUC: Add support for advertising muc#roomconfig_allowinvites in room disco#info 0.11
authorMatthew Wild <mwild1@gmail.com>
Mon, 10 May 2021 17:01:38 +0100
branch0.11
changeset 11549 7b8a482f4efd
parent 11548 c98aebe601f9
child 11550 b21d8c286973
MUC: Add support for advertising muc#roomconfig_allowinvites in room disco#info The de-facto interpretation of this (undocumented) option is to indicate to the client whether it is allowed to invite other users to the MUC. This is differs from the existing option in our config form, which only controls the behaviour of sending of invites in a members-only MUC (we always allow invites in open rooms). Conversations is one client known to use this disco#info item to determine whether it may send invites.
plugins/muc/members_only.lib.lua
--- a/plugins/muc/members_only.lib.lua	Mon May 10 16:50:24 2021 +0100
+++ b/plugins/muc/members_only.lib.lua	Mon May 10 17:01:38 2021 +0100
@@ -61,12 +61,20 @@
 end
 
 module:hook("muc-disco#info", function(event)
-	event.reply:tag("feature", {var = get_members_only(event.room) and "muc_membersonly" or "muc_open"}):up();
+	local members_only_room = not not get_members_only(event.room);
+	local members_can_invite = not not get_allow_member_invites(event.room);
+	event.reply:tag("feature", {var = members_only_room and "muc_membersonly" or "muc_open"}):up();
 	table.insert(event.form, {
 		name = "{http://prosody.im/protocol/muc}roomconfig_allowmemberinvites";
 		label = "Allow members to invite new members";
 		type = "boolean";
-		value = not not get_allow_member_invites(event.room);
+		value = members_can_invite;
+	});
+	table.insert(event.form, {
+		name = "muc#roomconfig_allowinvites";
+		label = "Allow users to invite other users";
+		type = "boolean";
+		value = not members_only_room or members_can_invite;
 	});
 end);