change_room_option/4, get_room_options/2,
set_room_affiliation/4, get_room_affiliations/2,
web_menu_main/2, web_page_main/2, web_menu_host/3,
- subscribe_room/4, unsubscribe_room/2,
+ subscribe_room/4, unsubscribe_room/2, get_subscribers/2,
web_page_host/3, mod_opt_type/1, get_commands_spec/0]).
-include("ejabberd.hrl").
module = ?MODULE, function = unsubscribe_room,
args = [{user, binary}, {room, binary}],
result = {res, rescode}},
+ #ejabberd_commands{name = get_subscribers, tags = [muc_room],
+ desc = "List subscribers of a MUC conference",
+ module = ?MODULE, function = get_subscribers,
+ args = [{name, binary}, {service, binary}],
+ result = {subscribers, {list, {jid, string}}}},
#ejabberd_commands{name = set_room_affiliation, tags = [muc_room],
desc = "Change an affiliation in a MUC room",
module = ?MODULE, function = set_room_affiliation,
throw({error, "Malformed room JID"})
end.
+get_subscribers(Name, Host) ->
+ case get_room_pid(Name, Host) of
+ Pid when is_pid(Pid) ->
+ {ok, JIDList} = gen_fsm:sync_send_all_state_event(Pid, get_subscribers),
+ [jid:to_string(jid:remove_resource(J)) || J <- JIDList];
+ _ ->
+ throw({error, "The room does not exist"})
+ end.
+
make_opts(StateData) ->
Config = StateData#state.config,
[
handle_sync_event({process_item_change, Item, UJID}, _From, StateName, StateData) ->
NSD = process_item_change(Item, StateData, UJID),
{reply, {ok, NSD}, StateName, NSD};
+handle_sync_event(get_subscribers, _From, StateName, StateData) ->
+ JIDs = dict:fold(
+ fun(_, #user{is_subscriber = true, jid = J}, Acc) ->
+ [J|Acc];
+ (_, _, Acc) ->
+ Acc
+ end, [], StateData#state.users),
+ {reply, {ok, JIDs}, StateName, StateData};
handle_sync_event({muc_subscribe, From, Nick, Nodes}, _From,
StateName, StateData) ->
SubEl = #xmlel{name = <<"subscribe">>,