]> granicus.if.org Git - ejabberd/commitdiff
Provide meaningful text to user when admin kicks session (EJAB-1455)
authorBadlop <badlop@process-one.net>
Wed, 26 Mar 2014 15:01:37 +0000 (16:01 +0100)
committerBadlop <badlop@process-one.net>
Wed, 26 Mar 2014 15:01:37 +0000 (16:01 +0100)
src/ejabberd_c2s.erl
src/mod_configure.erl

index fdaa8586d6b0c9f08910567841664d3ad0ceb8b4..83dfd2f07933320012437052d7ec6150e9d07363 100644 (file)
@@ -1217,14 +1217,15 @@ handle_info({send_text, Text}, StateName, StateData) ->
     send_text(StateData, Text),
     ejabberd_hooks:run(c2s_loop_debug, [Text]),
     fsm_next_state(StateName, StateData);
-handle_info(replaced, _StateName, StateData) ->
+handle_info(replaced, StateName, StateData) ->
     Lang = StateData#state.lang,
-    send_element(StateData,
-                ?SERRT_CONFLICT(Lang,
-                                <<"Replaced by new connection">>)),
+    Xmlelement = ?SERRT_CONFLICT(Lang, <<"Replaced by new connection">>),
+    handle_info({kick, replaced, Xmlelement}, StateName, StateData);
+handle_info({kick, Reason, Xmlelement}, _StateName, StateData) ->
+    send_element(StateData, Xmlelement),
     send_trailer(StateData),
     {stop, normal,
-     StateData#state{authenticated = replaced}};
+     StateData#state{authenticated = Reason}};
 handle_info({route, _From, _To, {broadcast, Data}},
             StateName, StateData) ->
     ?DEBUG("broadcast~n~p~n", [Data]),
index c8a8ebddd4e7fbcab9c438ab91a60076e99de857..d9c825b5c354076ae03457828a4dbb67932b1e37 100644 (file)
@@ -1846,13 +1846,14 @@ set_form(From, Host, ?NS_ADMINL(<<"delete-user">>),
      || {User, Server} <- ASL2],
     {result, []};
 set_form(From, Host, ?NS_ADMINL(<<"end-user-session">>),
-        _Lang, XData) ->
+        Lang, XData) ->
     AccountString = get_value(<<"accountjid">>, XData),
     JID = jlib:string_to_jid(AccountString),
     LUser = JID#jid.luser,
     LServer = JID#jid.lserver,
     true = LServer == Host orelse
             get_permission_level(From) == global,
+    Xmlelement = ?SERRT_POLICY_VIOLATION(Lang, <<"has been kicked">>),
     case JID#jid.lresource of
       <<>> ->
          SIDs = mnesia:dirty_select(session,
@@ -1860,14 +1861,14 @@ set_form(From, Host, ?NS_ADMINL(<<"end-user-session">>),
                                                usr = {LUser, LServer, '_'},
                                                _ = '_'},
                                       [], ['$1']}]),
-         [Pid ! replaced || {_, Pid} <- SIDs];
+         [Pid ! {kick, kicked_by_admin, Xmlelement} || {_, Pid} <- SIDs];
       R ->
          [{_, Pid}] = mnesia:dirty_select(session,
                                           [{#session{sid = '$1',
                                                      usr = {LUser, LServer, R},
                                                      _ = '_'},
                                             [], ['$1']}]),
-         Pid ! replaced
+         Pid ! {kick, kicked_by_admin, Xmlelement}
     end,
     {result, []};
 set_form(From, Host,