25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

Provide meaningful text to user when admin kicks session (EJAB-1455)

This commit is contained in:
Badlop 2014-03-26 16:01:37 +01:00
parent 2150b10901
commit ac0e199d36
2 changed files with 10 additions and 8 deletions

View File

@ -1217,14 +1217,15 @@ handle_info({send_text, Text}, StateName, StateData) ->
send_text(StateData, Text), send_text(StateData, Text),
ejabberd_hooks:run(c2s_loop_debug, [Text]), ejabberd_hooks:run(c2s_loop_debug, [Text]),
fsm_next_state(StateName, StateData); fsm_next_state(StateName, StateData);
handle_info(replaced, _StateName, StateData) -> handle_info(replaced, StateName, StateData) ->
Lang = StateData#state.lang, Lang = StateData#state.lang,
send_element(StateData, Xmlelement = ?SERRT_CONFLICT(Lang, <<"Replaced by new connection">>),
?SERRT_CONFLICT(Lang, handle_info({kick, replaced, Xmlelement}, StateName, StateData);
<<"Replaced by new connection">>)), handle_info({kick, Reason, Xmlelement}, _StateName, StateData) ->
send_element(StateData, Xmlelement),
send_trailer(StateData), send_trailer(StateData),
{stop, normal, {stop, normal,
StateData#state{authenticated = replaced}}; StateData#state{authenticated = Reason}};
handle_info({route, _From, _To, {broadcast, Data}}, handle_info({route, _From, _To, {broadcast, Data}},
StateName, StateData) -> StateName, StateData) ->
?DEBUG("broadcast~n~p~n", [Data]), ?DEBUG("broadcast~n~p~n", [Data]),

View File

@ -1846,13 +1846,14 @@ set_form(From, Host, ?NS_ADMINL(<<"delete-user">>),
|| {User, Server} <- ASL2], || {User, Server} <- ASL2],
{result, []}; {result, []};
set_form(From, Host, ?NS_ADMINL(<<"end-user-session">>), set_form(From, Host, ?NS_ADMINL(<<"end-user-session">>),
_Lang, XData) -> Lang, XData) ->
AccountString = get_value(<<"accountjid">>, XData), AccountString = get_value(<<"accountjid">>, XData),
JID = jlib:string_to_jid(AccountString), JID = jlib:string_to_jid(AccountString),
LUser = JID#jid.luser, LUser = JID#jid.luser,
LServer = JID#jid.lserver, LServer = JID#jid.lserver,
true = LServer == Host orelse true = LServer == Host orelse
get_permission_level(From) == global, get_permission_level(From) == global,
Xmlelement = ?SERRT_POLICY_VIOLATION(Lang, <<"has been kicked">>),
case JID#jid.lresource of case JID#jid.lresource of
<<>> -> <<>> ->
SIDs = mnesia:dirty_select(session, SIDs = mnesia:dirty_select(session,
@ -1860,14 +1861,14 @@ set_form(From, Host, ?NS_ADMINL(<<"end-user-session">>),
usr = {LUser, LServer, '_'}, usr = {LUser, LServer, '_'},
_ = '_'}, _ = '_'},
[], ['$1']}]), [], ['$1']}]),
[Pid ! replaced || {_, Pid} <- SIDs]; [Pid ! {kick, kicked_by_admin, Xmlelement} || {_, Pid} <- SIDs];
R -> R ->
[{_, Pid}] = mnesia:dirty_select(session, [{_, Pid}] = mnesia:dirty_select(session,
[{#session{sid = '$1', [{#session{sid = '$1',
usr = {LUser, LServer, R}, usr = {LUser, LServer, R},
_ = '_'}, _ = '_'},
[], ['$1']}]), [], ['$1']}]),
Pid ! replaced Pid ! {kick, kicked_by_admin, Xmlelement}
end, end,
{result, []}; {result, []};
set_form(From, Host, set_form(From, Host,