From 54c23a65db7491a9cc51eac3f89734c161603481 Mon Sep 17 00:00:00 2001 From: Badlop Date: Thu, 21 Oct 2021 12:44:51 +0200 Subject: Fix create_room_with_opts when using SQL storage (#3700) --- src/mod_muc_admin.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mod_muc_admin.erl') diff --git a/src/mod_muc_admin.erl b/src/mod_muc_admin.erl index 2abeee45c..ce4665d7e 100644 --- a/src/mod_muc_admin.erl +++ b/src/mod_muc_admin.erl @@ -710,7 +710,7 @@ create_room_with_opts(Name1, Host1, ServerHost1, CustomRoomOpts) -> maybe_store_room(ServerHost, Host, Name, RoomOpts) -> case proplists:get_bool(persistent, RoomOpts) of true -> - {atomic, ok} = mod_muc:store_room(ServerHost, Host, Name, RoomOpts), + {atomic, _} = mod_muc:store_room(ServerHost, Host, Name, RoomOpts), ok; false -> ok -- cgit v1.2.3 From 7e07cba406c46b2a682031a8a530425e8ecb5a1a Mon Sep 17 00:00:00 2001 From: Badlop Date: Mon, 13 Dec 2021 18:22:59 +0100 Subject: Let get_all_rooms handle "global" argument, fixes rooms_unsued_... (#3726) --- src/mod_muc_admin.erl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/mod_muc_admin.erl') diff --git a/src/mod_muc_admin.erl b/src/mod_muc_admin.erl index ce4665d7e..9952abd27 100644 --- a/src/mod_muc_admin.erl +++ b/src/mod_muc_admin.erl @@ -860,7 +860,14 @@ get_online_rooms(ServiceArg) -> || {RoomName, RoomHost, Pid} <- mod_muc:get_online_rooms(Host)] end, Hosts). -get_all_rooms(Host) -> +get_all_rooms(ServiceArg) -> + Hosts = find_services(ServiceArg), + lists:flatmap( + fun(Host) -> + get_all_rooms2(Host) + end, Hosts). + +get_all_rooms2(Host) -> ServerHost = ejabberd_router:host_of_route(Host), OnlineRooms = get_online_rooms(Host), OnlineMap = lists:foldl( -- cgit v1.2.3 From fc34661b6f9fe8d506fcd51269c5cefe05c74350 Mon Sep 17 00:00:00 2001 From: Alexey Shchepin Date: Mon, 20 Dec 2021 09:37:47 +0300 Subject: Add subscribe_room_many command --- src/mod_muc_admin.erl | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) (limited to 'src/mod_muc_admin.erl') diff --git a/src/mod_muc_admin.erl b/src/mod_muc_admin.erl index 9952abd27..21611c585 100644 --- a/src/mod_muc_admin.erl +++ b/src/mod_muc_admin.erl @@ -40,8 +40,11 @@ change_room_option/4, get_room_options/2, set_room_affiliation/4, get_room_affiliations/2, get_room_affiliation/3, web_menu_main/2, web_page_main/2, web_menu_host/3, - subscribe_room/4, unsubscribe_room/2, get_subscribers/2, - web_page_host/3, mod_options/1, get_commands_spec/0, find_hosts/1]). + subscribe_room/4, subscribe_room_many/3, + unsubscribe_room/2, get_subscribers/2, + web_page_host/3, + mod_opt_type/1, mod_options/1, + get_commands_spec/0, find_hosts/1]). -include("logger.hrl"). -include_lib("xmpp/include/xmpp.hrl"). @@ -331,6 +334,25 @@ get_commands_spec() -> args = [{user, binary}, {nick, binary}, {room, binary}, {nodes, binary}], result = {nodes, {list, {node, string}}}}, + #ejabberd_commands{name = subscribe_room_many, tags = [muc_room], + desc = "Subscribe several users to a MUC conference", + module = ?MODULE, function = subscribe_room_many, + args_desc = ["Users JIDs and nicks", + "the room to subscribe", + "nodes separated by commas: ,"], + args_example = [[{"tom@localhost", "Tom"}, + {"jerry@localhost", "Jerry"}], + "room1@conference.localhost", + "urn:xmpp:mucsub:nodes:messages,urn:xmpp:mucsub:nodes:affiliations"], + args = [{users, {list, + {user, {tuple, + [{jid, binary}, + {nick, binary} + ]}} + }}, + {room, binary}, + {nodes, binary}], + result = {res, rescode}}, #ejabberd_commands{name = unsubscribe_room, tags = [muc_room], desc = "Unsubscribe from a MUC conference", module = ?MODULE, function = unsubscribe_room, @@ -1331,6 +1353,18 @@ subscribe_room(User, Nick, Room, Nodes) -> throw({error, "Malformed room JID"}) end. +subscribe_room_many(Users, Room, Nodes) -> + MaxUsers = mod_muc_admin_opt:subscribe_room_many_max_users(global), + if + length(Users) > MaxUsers -> + throw({error, "Too many users in subscribe_room_many command"}); + true -> + lists:foreach( + fun({User, Nick}) -> + subscribe_room(User, Nick, Room, Nodes) + end, Users) + end. + unsubscribe_room(User, Room) -> try jid:decode(Room) of #jid{luser = Name, lserver = Host} when Name /= <<"">> -> @@ -1413,7 +1447,11 @@ find_hosts(ServerHost) -> [] end. -mod_options(_) -> []. +mod_opt_type(subscribe_room_many_max_users) -> + econf:int(). + +mod_options(_) -> + [{subscribe_room_many_max_users, 50}]. mod_doc() -> #{desc => -- cgit v1.2.3 From 9ba20d26cb67a0c6adcfb7d5fbbb3ba23c6cc9fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chmielowski?= Date: Wed, 5 Jan 2022 16:43:55 +0100 Subject: Add better descripion of subscribe_room_many command --- src/mod_muc_admin.erl | 1 + 1 file changed, 1 insertion(+) (limited to 'src/mod_muc_admin.erl') diff --git a/src/mod_muc_admin.erl b/src/mod_muc_admin.erl index 21611c585..6e533a3df 100644 --- a/src/mod_muc_admin.erl +++ b/src/mod_muc_admin.erl @@ -336,6 +336,7 @@ get_commands_spec() -> result = {nodes, {list, {node, string}}}}, #ejabberd_commands{name = subscribe_room_many, tags = [muc_room], desc = "Subscribe several users to a MUC conference", + longdesc = "This command accept up to 50 users at once (this is configurable with `subscribe_room_many_max_users` option)", module = ?MODULE, function = subscribe_room_many, args_desc = ["Users JIDs and nicks", "the room to subscribe", -- cgit v1.2.3 From ce14c28faf2ca47e14a3dcdaf9e336940ca89ca0 Mon Sep 17 00:00:00 2001 From: Badlop Date: Mon, 10 Jan 2022 16:45:35 +0100 Subject: Fix version when this command was really updated --- src/mod_muc_admin.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mod_muc_admin.erl') diff --git a/src/mod_muc_admin.erl b/src/mod_muc_admin.erl index 6e533a3df..d18ba5f07 100644 --- a/src/mod_muc_admin.erl +++ b/src/mod_muc_admin.erl @@ -284,7 +284,7 @@ get_commands_spec() -> #ejabberd_commands{name = send_direct_invitation, tags = [muc_room], desc = "Send a direct invitation to several destinations", - longdesc = "Since ejabberd 20.10, this command is " + longdesc = "Since ejabberd 20.12, this command is " "asynchronous: the API call may return before the " "server has send all the invitations.\n\n" "Password and Message can also be: none. " -- cgit v1.2.3 From 1fb908b70f8651f7074d8f1beefc5d4d2baf470b Mon Sep 17 00:00:00 2001 From: Badlop Date: Thu, 13 Jan 2022 19:27:53 +0100 Subject: Document option subscrube_room_many_max_users introduced in fc34661b6 --- src/mod_muc_admin.erl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/mod_muc_admin.erl') diff --git a/src/mod_muc_admin.erl b/src/mod_muc_admin.erl index d18ba5f07..ac2d887fe 100644 --- a/src/mod_muc_admin.erl +++ b/src/mod_muc_admin.erl @@ -1459,4 +1459,11 @@ mod_doc() -> [?T("This module provides commands to administer local MUC " "services and their MUC rooms. It also provides simple " "WebAdmin pages to view the existing rooms."), "", - ?T("This module depends on _`mod_muc`_.")]}. + ?T("This module depends on _`mod_muc`_.")], + opts => + [{subscribe_room_many_max_users, + #{value => ?T("Number"), + desc => + ?T("How many users can be subscribed to a room at once using " + "the 'subscribe_room_many' command. " + "The default value is '50'.")}}]}. -- cgit v1.2.3