diff options
Diffstat (limited to 'src/mod_admin_extra.erl')
-rw-r--r-- | src/mod_admin_extra.erl | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/src/mod_admin_extra.erl b/src/mod_admin_extra.erl index b12a80007..5aebd3ff2 100644 --- a/src/mod_admin_extra.erl +++ b/src/mod_admin_extra.erl @@ -863,26 +863,36 @@ connected_users_vhost(Host) -> dirty_get_sessions_list2() -> mnesia:dirty_select( session, - [{#session{usr = '$1', sid = '$2', priority = '$3', info = '$4', _ = '_'}, - [], - [['$1', '$2', '$3', '$4']]}]). + [{#session{usr = '$1', sid = {'$2', '$3'}, priority = '$4', info = '$5', + _ = '_'}, + [{is_pid, '$3'}], + [['$1', {{'$2', '$3'}}, '$4', '$5']]}]). %% Make string more print-friendly stringize(String) -> %% Replace newline characters with other code ejabberd_regexp:greplace(String, <<"\n">>, <<"\\n">>). +set_presence(User, Host, Resource, Type, Show, Status, Priority) + when is_integer(Priority) -> + BPriority = integer_to_binary(Priority), + set_presence(User, Host, Resource, Type, Show, Status, BPriority); set_presence(User, Host, Resource, Type, Show, Status, Priority) -> - Pid = ejabberd_sm:get_session_pid(User, Host, Resource), - USR = jid:to_string(jid:make(User, Host, Resource)), - US = jid:to_string(jid:make(User, Host, <<>>)), - Message = {route_xmlstreamelement, - {xmlel, <<"presence">>, - [{<<"from">>, USR}, {<<"to">>, US}, {<<"type">>, Type}], - [{xmlel, <<"show">>, [], [{xmlcdata, Show}]}, - {xmlel, <<"status">>, [], [{xmlcdata, Status}]}, - {xmlel, <<"priority">>, [], [{xmlcdata, Priority}]}]}}, - Pid ! Message. + case ejabberd_sm:get_session_pid(User, Host, Resource) of + none -> + error; + Pid -> + USR = jid:to_string(jid:make(User, Host, Resource)), + US = jid:to_string(jid:make(User, Host, <<>>)), + Message = {route_xmlstreamelement, + {xmlel, <<"presence">>, + [{<<"from">>, USR}, {<<"to">>, US}, {<<"type">>, Type}], + [{xmlel, <<"show">>, [], [{xmlcdata, Show}]}, + {xmlel, <<"status">>, [], [{xmlcdata, Status}]}, + {xmlel, <<"priority">>, [], [{xmlcdata, Priority}]}]}}, + Pid ! Message, + ok + end. user_sessions_info(User, Host) -> CurrentSec = calendar:datetime_to_gregorian_seconds({date(), time()}), @@ -891,7 +901,9 @@ user_sessions_info(User, Host) -> {'EXIT', _Reason} -> []; Ss -> - Ss + lists:filter(fun(#session{sid = {_, Pid}}) -> + is_pid(Pid) + end, Ss) end, lists:map( fun(Session) -> |