mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
Optimize user removal handling in mod_muc
This commit is contained in:
parent
536beedeb6
commit
a26c9d2475
@ -1143,9 +1143,9 @@ remove_user(User, Server) ->
|
||||
fun(Host) ->
|
||||
lists:foreach(
|
||||
fun({_, _, Pid}) ->
|
||||
mod_muc_room:change_item(
|
||||
mod_muc_room:change_item_async(
|
||||
Pid, JID, affiliation, none, <<"User removed">>),
|
||||
mod_muc_room:change_item(
|
||||
mod_muc_room:change_item_async(
|
||||
Pid, JID, role, none, <<"User removed">>)
|
||||
end,
|
||||
get_online_rooms(LServer, Host))
|
||||
|
@ -50,6 +50,7 @@
|
||||
set_config/2,
|
||||
get_state/1,
|
||||
change_item/5,
|
||||
change_item_async/5,
|
||||
config_reloaded/1,
|
||||
subscribe/4,
|
||||
unsubscribe/2,
|
||||
@ -202,6 +203,11 @@ change_item(Pid, JID, Type, AffiliationOrRole, Reason) ->
|
||||
{error, notfound}
|
||||
end.
|
||||
|
||||
-spec change_item_async(pid(), jid(), affiliation | role, affiliation() | role(), binary()) -> ok.
|
||||
change_item_async(Pid, JID, Type, AffiliationOrRole, Reason) ->
|
||||
p1_fsm:send_all_state_event(
|
||||
Pid, {process_item_change, {JID, Type, AffiliationOrRole, Reason}, undefined}).
|
||||
|
||||
-spec get_state(pid()) -> {ok, state()} | {error, notfound | timeout}.
|
||||
get_state(Pid) ->
|
||||
try p1_fsm:sync_send_all_state_event(Pid, get_state)
|
||||
@ -675,6 +681,16 @@ handle_event({set_affiliations, Affiliations},
|
||||
StateName, StateData) ->
|
||||
NewStateData = set_affiliations(Affiliations, StateData),
|
||||
{next_state, StateName, NewStateData};
|
||||
handle_event({process_item_change, Item, UJID}, StateName, StateData) ->
|
||||
case process_item_change(Item, StateData, UJID) of
|
||||
{error, _} ->
|
||||
{next_state, StateName, StateData};
|
||||
StateData ->
|
||||
{next_state, StateName, StateData};
|
||||
NSD ->
|
||||
store_room(NSD),
|
||||
{next_state, StateName, NSD}
|
||||
end;
|
||||
handle_event(_Event, StateName, StateData) ->
|
||||
{next_state, StateName, StateData}.
|
||||
|
||||
@ -723,6 +739,8 @@ handle_sync_event({process_item_change, Item, UJID}, _From, StateName, StateData
|
||||
case process_item_change(Item, StateData, UJID) of
|
||||
{error, _} = Err ->
|
||||
{reply, Err, StateName, StateData};
|
||||
StateData ->
|
||||
{reply, {ok, StateData}, StateName, StateData};
|
||||
NSD ->
|
||||
store_room(NSD),
|
||||
{reply, {ok, NSD}, StateName, NSD}
|
||||
|
Loading…
Reference in New Issue
Block a user