mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-26 17:38:45 +01:00
Add get_subscribers command to list MUC subscribers
This commit is contained in:
parent
af2999a783
commit
417284a921
@ -20,7 +20,7 @@
|
|||||||
change_room_option/4, get_room_options/2,
|
change_room_option/4, get_room_options/2,
|
||||||
set_room_affiliation/4, get_room_affiliations/2,
|
set_room_affiliation/4, get_room_affiliations/2,
|
||||||
web_menu_main/2, web_page_main/2, web_menu_host/3,
|
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]).
|
web_page_host/3, mod_opt_type/1, get_commands_spec/0]).
|
||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
@ -163,6 +163,11 @@ get_commands_spec() ->
|
|||||||
module = ?MODULE, function = unsubscribe_room,
|
module = ?MODULE, function = unsubscribe_room,
|
||||||
args = [{user, binary}, {room, binary}],
|
args = [{user, binary}, {room, binary}],
|
||||||
result = {res, rescode}},
|
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],
|
#ejabberd_commands{name = set_room_affiliation, tags = [muc_room],
|
||||||
desc = "Change an affiliation in a MUC room",
|
desc = "Change an affiliation in a MUC room",
|
||||||
module = ?MODULE, function = set_room_affiliation,
|
module = ?MODULE, function = set_room_affiliation,
|
||||||
@ -955,6 +960,15 @@ unsubscribe_room(User, Room) ->
|
|||||||
throw({error, "Malformed room JID"})
|
throw({error, "Malformed room JID"})
|
||||||
end.
|
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) ->
|
make_opts(StateData) ->
|
||||||
Config = StateData#state.config,
|
Config = StateData#state.config,
|
||||||
[
|
[
|
||||||
|
@ -749,6 +749,14 @@ handle_sync_event({change_state, NewStateData}, _From,
|
|||||||
handle_sync_event({process_item_change, Item, UJID}, _From, StateName, StateData) ->
|
handle_sync_event({process_item_change, Item, UJID}, _From, StateName, StateData) ->
|
||||||
NSD = process_item_change(Item, StateData, UJID),
|
NSD = process_item_change(Item, StateData, UJID),
|
||||||
{reply, {ok, NSD}, StateName, NSD};
|
{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,
|
handle_sync_event({muc_subscribe, From, Nick, Nodes}, _From,
|
||||||
StateName, StateData) ->
|
StateName, StateData) ->
|
||||||
SubEl = #xmlel{name = <<"subscribe">>,
|
SubEl = #xmlel{name = <<"subscribe">>,
|
||||||
|
Loading…
Reference in New Issue
Block a user