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) ->
|
fun(Host) ->
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun({_, _, Pid}) ->
|
fun({_, _, Pid}) ->
|
||||||
mod_muc_room:change_item(
|
mod_muc_room:change_item_async(
|
||||||
Pid, JID, affiliation, none, <<"User removed">>),
|
Pid, JID, affiliation, none, <<"User removed">>),
|
||||||
mod_muc_room:change_item(
|
mod_muc_room:change_item_async(
|
||||||
Pid, JID, role, none, <<"User removed">>)
|
Pid, JID, role, none, <<"User removed">>)
|
||||||
end,
|
end,
|
||||||
get_online_rooms(LServer, Host))
|
get_online_rooms(LServer, Host))
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
set_config/2,
|
set_config/2,
|
||||||
get_state/1,
|
get_state/1,
|
||||||
change_item/5,
|
change_item/5,
|
||||||
|
change_item_async/5,
|
||||||
config_reloaded/1,
|
config_reloaded/1,
|
||||||
subscribe/4,
|
subscribe/4,
|
||||||
unsubscribe/2,
|
unsubscribe/2,
|
||||||
@ -202,6 +203,11 @@ change_item(Pid, JID, Type, AffiliationOrRole, Reason) ->
|
|||||||
{error, notfound}
|
{error, notfound}
|
||||||
end.
|
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}.
|
-spec get_state(pid()) -> {ok, state()} | {error, notfound | timeout}.
|
||||||
get_state(Pid) ->
|
get_state(Pid) ->
|
||||||
try p1_fsm:sync_send_all_state_event(Pid, get_state)
|
try p1_fsm:sync_send_all_state_event(Pid, get_state)
|
||||||
@ -675,6 +681,16 @@ handle_event({set_affiliations, Affiliations},
|
|||||||
StateName, StateData) ->
|
StateName, StateData) ->
|
||||||
NewStateData = set_affiliations(Affiliations, StateData),
|
NewStateData = set_affiliations(Affiliations, StateData),
|
||||||
{next_state, StateName, NewStateData};
|
{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) ->
|
handle_event(_Event, StateName, StateData) ->
|
||||||
{next_state, 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
|
case process_item_change(Item, StateData, UJID) of
|
||||||
{error, _} = Err ->
|
{error, _} = Err ->
|
||||||
{reply, Err, StateName, StateData};
|
{reply, Err, StateName, StateData};
|
||||||
|
StateData ->
|
||||||
|
{reply, {ok, StateData}, StateName, StateData};
|
||||||
NSD ->
|
NSD ->
|
||||||
store_room(NSD),
|
store_room(NSD),
|
||||||
{reply, {ok, NSD}, StateName, NSD}
|
{reply, {ok, NSD}, StateName, NSD}
|
||||||
|
Loading…
Reference in New Issue
Block a user