diff options
author | Alexey Shchepin <alexey@process-one.net> | 2021-12-20 09:31:01 +0300 |
---|---|---|
committer | Alexey Shchepin <alexey@process-one.net> | 2021-12-20 09:42:02 +0300 |
commit | a26c9d2475beaa9398d8815f861ed0b1025edc58 (patch) | |
tree | c96f9832680fe67e30c07f351ee09de201a7207d /src/mod_muc_room.erl | |
parent | Accept more types of ejabberdctl commands arguments as JSON-encoded (diff) |
Optimize user removal handling in mod_muc
Diffstat (limited to 'src/mod_muc_room.erl')
-rw-r--r-- | src/mod_muc_room.erl | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/mod_muc_room.erl b/src/mod_muc_room.erl index ec1c551e4..25bc7d8b6 100644 --- a/src/mod_muc_room.erl +++ b/src/mod_muc_room.erl @@ -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} |