mirror of
https://github.com/processone/ejabberd
synced 2025-10-03 01:39:35 +02:00
fix: unsubscribe users from members-only rooms when expelled
Fixes #4410
This commit is contained in:
parent
a64aa9e280
commit
e709f99b47
1 changed files with 26 additions and 0 deletions
|
@ -3221,6 +3221,7 @@ process_item_change(Item, SD, UJID) ->
|
||||||
true ->
|
true ->
|
||||||
send_kickban_presence(UJID, JID, Reason, 321, none, SD),
|
send_kickban_presence(UJID, JID, Reason, 321, none, SD),
|
||||||
maybe_send_affiliation(JID, none, SD),
|
maybe_send_affiliation(JID, none, SD),
|
||||||
|
unsubscribe_from_room(JID, SD),
|
||||||
SD1 = set_affiliation(JID, none, SD),
|
SD1 = set_affiliation(JID, none, SD),
|
||||||
set_role(JID, none, SD1);
|
set_role(JID, none, SD1);
|
||||||
_ ->
|
_ ->
|
||||||
|
@ -3237,6 +3238,7 @@ process_item_change(Item, SD, UJID) ->
|
||||||
{JID, affiliation, outcast, Reason} ->
|
{JID, affiliation, outcast, Reason} ->
|
||||||
send_kickban_presence(UJID, JID, Reason, 301, outcast, SD),
|
send_kickban_presence(UJID, JID, Reason, 301, outcast, SD),
|
||||||
maybe_send_affiliation(JID, outcast, SD),
|
maybe_send_affiliation(JID, outcast, SD),
|
||||||
|
unsubscribe_from_room(JID, SD),
|
||||||
{result, undefined, SD2} =
|
{result, undefined, SD2} =
|
||||||
process_iq_mucsub(JID,
|
process_iq_mucsub(JID,
|
||||||
#iq{type = set,
|
#iq{type = set,
|
||||||
|
@ -3279,6 +3281,30 @@ process_item_change(Item, SD, UJID) ->
|
||||||
{error, xmpp:err_internal_server_error()}
|
{error, xmpp:err_internal_server_error()}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
-spec unsubscribe_from_room(jid(), state()) -> ok | error.
|
||||||
|
unsubscribe_from_room(JID, SD) ->
|
||||||
|
case SD#state.config#config.members_only of
|
||||||
|
false ->
|
||||||
|
ok;
|
||||||
|
true ->
|
||||||
|
case mod_muc:unhibernate_room(SD#state.server_host, SD#state.host, SD#state.room) of
|
||||||
|
{error, Reason0} ->
|
||||||
|
error;
|
||||||
|
{ok, Pid} ->
|
||||||
|
_UnsubPid =
|
||||||
|
spawn(fun() ->
|
||||||
|
case unsubscribe(Pid, JID) of
|
||||||
|
ok ->
|
||||||
|
ok;
|
||||||
|
{error, Reason} ->
|
||||||
|
?WARNING_MSG("Failed to automatically unsubscribe expelled member from room: ~ts",
|
||||||
|
[Reason]),
|
||||||
|
error
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end.
|
||||||
|
|
||||||
-spec find_changed_items(jid(), affiliation(), role(),
|
-spec find_changed_items(jid(), affiliation(), role(),
|
||||||
[muc_item()], binary(), state(), [admin_action()]) ->
|
[muc_item()], binary(), state(), [admin_action()]) ->
|
||||||
{result, [admin_action()]}.
|
{result, [admin_action()]}.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue