aboutsummaryrefslogtreecommitdiff
path: root/src/mod_muc_admin.erl
diff options
context:
space:
mode:
authorBadlop <badlop@process-one.net>2021-03-08 20:43:33 +0100
committerBadlop <badlop@process-one.net>2021-03-09 00:57:41 +0100
commit0f43c2c52848d2ef6e67e90ec39ed902b5db519b (patch)
treee08b9137e89b6b96750ca2c0592bfc14d5e0b42e /src/mod_muc_admin.erl
parentShow in WebAdmin the erlang node where the room resides (diff)
New command get_user_subscriptions (#3403)
Diffstat (limited to '')
-rw-r--r--src/mod_muc_admin.erl28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/mod_muc_admin.erl b/src/mod_muc_admin.erl
index 9e447301e..38d3a8220 100644
--- a/src/mod_muc_admin.erl
+++ b/src/mod_muc_admin.erl
@@ -35,7 +35,7 @@
create_rooms_file/1, destroy_rooms_file/1,
rooms_unused_list/2, rooms_unused_destroy/2,
rooms_empty_list/1, rooms_empty_destroy/1,
- get_user_rooms/2, get_room_occupants/2,
+ get_user_rooms/2, get_user_subscriptions/2, get_room_occupants/2,
get_room_occupants_number/2, send_direct_invitation/5,
change_room_option/4, get_room_options/2,
set_room_affiliation/4, get_room_affiliations/2, get_room_affiliation/3,
@@ -235,6 +235,22 @@ get_commands_spec() ->
result_example = ["room1@muc.example.com", "room2@muc.example.com"],
args = [{user, binary}, {host, binary}],
result = {rooms, {list, {room, string}}}},
+ #ejabberd_commands{name = get_user_subscriptions, tags = [muc],
+ desc = "Get the list of rooms where this user is subscribed",
+ module = ?MODULE, function = get_user_subscriptions,
+ args_desc = ["Username", "Server host"],
+ args_example = ["tom", "example.com"],
+ result_example = [{"room1@muc.example.com", "Tommy", ["mucsub:config"]}],
+ args = [{user, binary}, {host, binary}],
+ result = {rooms,
+ {list,
+ {room,
+ {tuple,
+ [{roomjid, string},
+ {usernick, string},
+ {nodes, {list, {node, string}}}
+ ]}}
+ }}},
#ejabberd_commands{name = get_room_occupants, tags = [muc_room],
desc = "Get the list of occupants of a MUC room",
@@ -443,6 +459,16 @@ get_user_rooms(User, Server) ->
end
end, ejabberd_option:hosts()).
+get_user_subscriptions(User, Server) ->
+ Services = find_services(global),
+ UserJid = jid:make(jid:nodeprep(User), jid:nodeprep(Server)),
+ lists:flatmap(
+ fun(ServerHost) ->
+ {ok, Rooms} = mod_muc:get_subscribed_rooms(ServerHost, UserJid),
+ [{jid:encode(RoomJid), UserNick, Nodes}
+ || {RoomJid, UserNick, Nodes} <- Rooms]
+ end, Services).
+
%%----------------------------
%% Ad-hoc commands
%%----------------------------