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

Don't call modules that were obsoleted by GS

This commit is contained in:
Badlop 2010-07-30 13:21:25 +02:00
parent 8a5b08e3f0
commit 92dc45ad76
8 changed files with 67 additions and 139 deletions

View File

@ -15,10 +15,9 @@
ejabberd_auth_anonymous, ejabberd_auth_anonymous,
ejabberd_auth, ejabberd_auth,
ejabberd_auth_external, ejabberd_auth_external,
ejabberd_auth_internal,
ejabberd_auth_ldap, ejabberd_auth_ldap,
ejabberd_auth_odbc,
ejabberd_auth_pam, ejabberd_auth_pam,
ejabberd_auth_storage,
ejabberd, ejabberd,
ejabberd_c2s, ejabberd_c2s,
ejabberd_c2s_config, ejabberd_c2s_config,
@ -75,16 +74,12 @@
mod_http_bind, mod_http_bind,
mod_http_fileserver, mod_http_fileserver,
mod_last, mod_last,
mod_last_odbc,
mod_muc, mod_muc,
mod_muc_log, mod_muc_log,
mod_muc_room, mod_muc_room,
mod_offline, mod_offline,
mod_offline_odbc,
mod_privacy, mod_privacy,
mod_privacy_odbc,
mod_private, mod_private,
mod_private_odbc,
mod_proxy65, mod_proxy65,
mod_proxy65_lib, mod_proxy65_lib,
mod_proxy65_service, mod_proxy65_service,
@ -93,14 +88,12 @@
mod_pubsub, mod_pubsub,
mod_register, mod_register,
mod_roster, mod_roster,
mod_roster_odbc,
mod_service_log, mod_service_log,
mod_shared_roster, mod_shared_roster,
mod_stats, mod_stats,
mod_time, mod_time,
mod_vcard, mod_vcard,
mod_vcard_ldap, mod_vcard_ldap,
mod_vcard_odbc,
mod_version, mod_version,
node_buddy, node_buddy,
node_club, node_club,

View File

@ -66,8 +66,8 @@
-include("ejabberd.hrl"). -include("ejabberd.hrl").
%% @type authmodule() = ejabberd_auth_anonymous | ejabberd_auth_external | %% @type authmodule() = ejabberd_auth_anonymous | ejabberd_auth_external |
%% ejabberd_auth_internal | ejabberd_auth_ldap | %% ejabberd_auth_ldap | ejabberd_auth_pam |
%% ejabberd_auth_odbc | ejabberd_auth_pam | atom(). %% ejabberd_auth_storage | atom().
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
%%% API %%% API

View File

@ -60,7 +60,7 @@ start(Host) ->
Host, ejabberd_config:get_local_option({extauth_program, Host})), Host, ejabberd_config:get_local_option({extauth_program, Host})),
case check_cache_last_options(Host) of case check_cache_last_options(Host) of
cache -> cache ->
ok = ejabberd_auth_internal:start(Host); ok = ejabberd_auth_storage:start(Host);
no_cache -> no_cache ->
ok ok
end. end.
@ -112,7 +112,7 @@ check_password(User, Server, Password, _Digest, _DigestGen) ->
set_password(User, Server, Password) -> set_password(User, Server, Password) ->
case extauth:set_password(User, Server, Password) of case extauth:set_password(User, Server, Password) of
true -> set_password_internal(User, Server, Password), true -> set_password_storage(User, Server, Password),
ok; ok;
_ -> {error, unknown_problem} _ -> {error, unknown_problem}
end. end.
@ -133,22 +133,22 @@ try_register(User, Server, Password) ->
%% @doc Return the list of all users handled by external. %% @doc Return the list of all users handled by external.
dirty_get_registered_users() -> dirty_get_registered_users() ->
ejabberd_auth_internal:dirty_get_registered_users(). ejabberd_auth_storage:dirty_get_registered_users().
get_vh_registered_users(Server) -> get_vh_registered_users(Server) ->
ejabberd_auth_internal:get_vh_registered_users(Server). ejabberd_auth_storage:get_vh_registered_users(Server).
get_vh_registered_users(Server, Data) -> get_vh_registered_users(Server, Data) ->
ejabberd_auth_internal:get_vh_registered_users(Server, Data). ejabberd_auth_storage:get_vh_registered_users(Server, Data).
%% @spec (Server) -> nil() %% @spec (Server) -> nil()
%% Server = string() %% Server = string()
get_vh_registered_users_number(Server) -> get_vh_registered_users_number(Server) ->
ejabberd_auth_internal:get_vh_registered_users_number(Server). ejabberd_auth_storage:get_vh_registered_users_number(Server).
get_vh_registered_users_number(Server, Data) -> get_vh_registered_users_number(Server, Data) ->
ejabberd_auth_internal:get_vh_registered_users_number(Server, Data). ejabberd_auth_storage:get_vh_registered_users_number(Server, Data).
%% @spec (User, Server) -> bool() %% @spec (User, Server) -> bool()
%% User = string() %% User = string()
@ -194,7 +194,7 @@ remove_user(User, Server) ->
case get_cache_option(Server) of case get_cache_option(Server) of
false -> false; false -> false;
{true, _CacheTime} -> {true, _CacheTime} ->
ejabberd_auth_internal:remove_user(User, Server) ejabberd_auth_storage:remove_user(User, Server)
end end
end. end.
@ -210,7 +210,7 @@ remove_user(User, Server, Password) ->
case get_cache_option(Server) of case get_cache_option(Server) of
false -> false; false -> false;
{true, _CacheTime} -> {true, _CacheTime} ->
ejabberd_auth_internal:remove_user(User, Server, Password) ejabberd_auth_storage:remove_user(User, Server, Password)
end end
end. end.
@ -236,7 +236,7 @@ try_register_extauth(User, Server, Password) ->
check_password_cache(User, Server, Password, CacheTime) -> check_password_cache(User, Server, Password, CacheTime) ->
case get_last_access(User, Server) of case get_last_access(User, Server) of
online -> online ->
check_password_internal(User, Server, Password); check_password_storage(User, Server, Password);
never -> never ->
check_password_external_cache(User, Server, Password); check_password_external_cache(User, Server, Password);
mod_last_required -> mod_last_required ->
@ -247,7 +247,7 @@ check_password_cache(User, Server, Password, CacheTime) ->
case is_fresh_enough(TimeStamp, CacheTime) of case is_fresh_enough(TimeStamp, CacheTime) of
%% If no need to refresh, check password against Mnesia %% If no need to refresh, check password against Mnesia
true -> true ->
case check_password_internal(User, Server, Password) of case check_password_storage(User, Server, Password) of
%% If password valid in Mnesia, accept it %% If password valid in Mnesia, accept it
true -> true ->
true; true;
@ -261,14 +261,14 @@ check_password_cache(User, Server, Password, CacheTime) ->
end end
end. end.
get_password_internal(User, Server) -> get_password_storage(User, Server) ->
ejabberd_auth_internal:get_password(User, Server). ejabberd_auth_storage:get_password(User, Server).
%% @spec (User, Server, CacheTime) -> Password::string() | false %% @spec (User, Server, CacheTime) -> Password::string() | false
get_password_cache(User, Server, CacheTime) -> get_password_cache(User, Server, CacheTime) ->
case get_last_access(User, Server) of case get_last_access(User, Server) of
online -> online ->
get_password_internal(User, Server); get_password_storage(User, Server);
never -> never ->
false; false;
mod_last_required -> mod_last_required ->
@ -277,7 +277,7 @@ get_password_cache(User, Server, CacheTime) ->
TimeStamp -> TimeStamp ->
case is_fresh_enough(TimeStamp, CacheTime) of case is_fresh_enough(TimeStamp, CacheTime) of
true -> true ->
get_password_internal(User, Server); get_password_storage(User, Server);
false -> false ->
false false
end end
@ -288,7 +288,7 @@ get_password_cache(User, Server, CacheTime) ->
check_password_external_cache(User, Server, Password) -> check_password_external_cache(User, Server, Password) ->
case check_password_extauth(User, Server, Password) of case check_password_extauth(User, Server, Password) of
true -> true ->
set_password_internal(User, Server, Password), true; set_password_storage(User, Server, Password), true;
false -> false ->
false false
end. end.
@ -297,18 +297,18 @@ check_password_external_cache(User, Server, Password) ->
try_register_external_cache(User, Server, Password) -> try_register_external_cache(User, Server, Password) ->
case try_register_extauth(User, Server, Password) of case try_register_extauth(User, Server, Password) of
{atomic, ok} = R -> {atomic, ok} = R ->
set_password_internal(User, Server, Password), set_password_storage(User, Server, Password),
R; R;
_ -> {error, not_allowed} _ -> {error, not_allowed}
end. end.
%% @spec (User, Server, Password) -> true | false %% @spec (User, Server, Password) -> true | false
check_password_internal(User, Server, Password) -> check_password_storage(User, Server, Password) ->
ejabberd_auth_internal:check_password(User, Server, Password). ejabberd_auth_storage:check_password(User, Server, Password).
%% @spec (User, Server, Password) -> ok | {error, invalid_jid} %% @spec (User, Server, Password) -> ok | {error, invalid_jid}
set_password_internal(User, Server, Password) -> set_password_storage(User, Server, Password) ->
ejabberd_auth_internal:set_password(User, Server, Password). ejabberd_auth_storage:set_password(User, Server, Password).
%% @spec (TimeLast, CacheTime) -> true | false %% @spec (TimeLast, CacheTime) -> true | false
%% TimeLast = online | never | integer() %% TimeLast = online | never | integer()
@ -347,19 +347,15 @@ get_last_access(UserS, ServerS) ->
get_last_info(User, Server) -> get_last_info(User, Server) ->
case get_mod_last_enabled(Server) of case get_mod_last_enabled(Server) of
mod_last -> mod_last:get_last_info(User, Server); mod_last -> mod_last:get_last_info(User, Server);
mod_last_odbc -> mod_last_odbc:get_last_info(User, Server);
no_mod_last -> mod_last_required no_mod_last -> mod_last_required
end. end.
%% @spec (Server) -> mod_last | mod_last_odbc | no_mod_last %% @spec (Server) -> mod_last | no_mod_last
get_mod_last_enabled(ServerB) when is_binary(ServerB)-> get_mod_last_enabled(ServerB) when is_binary(ServerB)->
Server = binary_to_list(ServerB), Server = binary_to_list(ServerB),
get_mod_last_enabled(Server); get_mod_last_enabled(Server);
get_mod_last_enabled(Server) -> get_mod_last_enabled(Server) ->
ML = lists:member(mod_last, gen_mod:loaded_modules(Server)), case lists:member(mod_last, gen_mod:loaded_modules(Server)) of
MLO = lists:member(mod_last_odbc, gen_mod:loaded_modules(Server)), true -> mod_last;
case {ML, MLO} of false -> no_mod_last
{true, _} -> mod_last;
{false, true} -> mod_last_odbc;
{false, false} -> no_mod_last
end. end.

View File

@ -227,7 +227,7 @@ create_user(User,Password,Domain) ->
populate_user(User,Domain,El=#xmlel{name='query', ns='jabber:iq:roster'}) -> populate_user(User,Domain,El=#xmlel{name='query', ns='jabber:iq:roster'}) ->
io:format("Trying to add/update roster list...",[]), io:format("Trying to add/update roster list...",[]),
case loaded_module(Domain,[mod_roster_odbc,mod_roster]) of case loaded_module(Domain,[mod_roster]) of
{ok, M} -> {ok, M} ->
case M:set_items(User, Domain, El) of case M:set_items(User, Domain, El) of
{atomic, ok} -> {atomic, ok} ->
@ -240,7 +240,7 @@ populate_user(User,Domain,El=#xmlel{name='query', ns='jabber:iq:roster'}) ->
{error, not_found} {error, not_found}
end; end;
E -> io:format(" ERROR: ~p~n",[E]), E -> io:format(" ERROR: ~p~n",[E]),
?ERROR_MSG("No modules loaded [mod_roster, mod_roster_odbc] ~s ~n", ?ERROR_MSG("Module not loaded: mod_roster ~s ~n",
[exmpp_xml:document_to_list(El)]), [exmpp_xml:document_to_list(El)]),
{error, not_found} {error, not_found}
end; end;
@ -268,7 +268,7 @@ populate_user(User,Domain,El=#xmlel{name='query', ns='jabber:iq:roster'}) ->
populate_user(User,Domain,El=#xmlel{name='vCard', ns='vcard-temp'}) -> populate_user(User,Domain,El=#xmlel{name='vCard', ns='vcard-temp'}) ->
io:format("Trying to add/update vCards...",[]), io:format("Trying to add/update vCards...",[]),
case loaded_module(Domain,[mod_vcard,mod_vcard_odbc]) of case loaded_module(Domain,[mod_vcard]) of
{ok, M} -> FullUser = exmpp_jid:make(User, Domain), {ok, M} -> FullUser = exmpp_jid:make(User, Domain),
IQ = #iq{kind=request, type = set, payload = El}, IQ = #iq{kind=request, type = set, payload = El},
case M:process_sm_iq(FullUser, FullUser , IQ) of case M:process_sm_iq(FullUser, FullUser , IQ) of
@ -281,7 +281,7 @@ populate_user(User,Domain,El=#xmlel{name='vCard', ns='vcard-temp'}) ->
end; end;
_ -> _ ->
io:format(" ERROR.~n",[]), io:format(" ERROR.~n",[]),
?ERROR_MSG("No modules loaded [mod_vcard, mod_vcard_odbc] ~s ~n", ?ERROR_MSG("Module not loaded: mod_vcard ~s ~n",
[exmpp_xml:document_to_list(El)]), [exmpp_xml:document_to_list(El)]),
{error, not_found} {error, not_found}
end; end;
@ -294,7 +294,7 @@ populate_user(User,Domain,El=#xmlel{name='vCard', ns='vcard-temp'}) ->
populate_user(User,Domain,El=#xmlel{name='offline-messages'}) -> populate_user(User,Domain,El=#xmlel{name='offline-messages'}) ->
io:format("Trying to add/update offline-messages...",[]), io:format("Trying to add/update offline-messages...",[]),
case loaded_module(Domain, [mod_offline, mod_offline_odbc]) of case loaded_module(Domain, [mod_offline]) of
{ok, M} -> {ok, M} ->
ok = exmpp_xml:foreach( ok = exmpp_xml:foreach(
fun (_Element, {xmlcdata, _}) -> fun (_Element, {xmlcdata, _}) ->
@ -307,7 +307,7 @@ populate_user(User,Domain,El=#xmlel{name='offline-messages'}) ->
end, El), io:format(" DONE.~n",[]); end, El), io:format(" DONE.~n",[]);
_ -> _ ->
io:format(" ERROR.~n",[]), io:format(" ERROR.~n",[]),
?ERROR_MSG("No modules loaded [mod_offline, mod_offline_odbc] ~s ~n", ?ERROR_MSG("Module not loaded: mod_offline ~s ~n",
[exmpp_xml:document_to_list(El)]), [exmpp_xml:document_to_list(El)]),
{error, not_found} {error, not_found}
end; end;
@ -320,7 +320,7 @@ populate_user(User,Domain,El=#xmlel{name='offline-messages'}) ->
populate_user(User,Domain,El=#xmlel{name='query', ns='jabber:iq:private'}) -> populate_user(User,Domain,El=#xmlel{name='query', ns='jabber:iq:private'}) ->
io:format("Trying to add/update private storage...",[]), io:format("Trying to add/update private storage...",[]),
case loaded_module(Domain,[mod_private_odbc,mod_private]) of case loaded_module(Domain,[mod_private]) of
{ok, M} -> {ok, M} ->
FullUser = exmpp_jid:make(User, Domain), FullUser = exmpp_jid:make(User, Domain),
IQ = #iq{type = set, IQ = #iq{type = set,
@ -337,7 +337,7 @@ populate_user(User,Domain,El=#xmlel{name='query', ns='jabber:iq:private'}) ->
end; end;
_ -> _ ->
io:format(" ERROR.~n",[]), io:format(" ERROR.~n",[]),
?ERROR_MSG("No modules loaded [mod_private, mod_private_odbc] ~s~n", ?ERROR_MSG("Module not loaded: mod_private ~s~n",
[exmpp_xml:document_to_list(El)]), [exmpp_xml:document_to_list(El)]),
{error, not_found} {error, not_found}
end; end;
@ -482,7 +482,7 @@ extract_user(Username, Host) ->
%% @spec (InfoName::atom(), Username::string(), Host::string()) -> string() %% @spec (InfoName::atom(), Username::string(), Host::string()) -> string()
extract_user_info(roster, Username, Host) -> extract_user_info(roster, Username, Host) ->
case loaded_module(Host,[mod_roster_odbc,mod_roster]) of case loaded_module(Host,[mod_roster]) of
{ok, M} -> {ok, M} ->
From = To = exmpp_jid:make(Username, Host, ""), From = To = exmpp_jid:make(Username, Host, ""),
SubelGet = exmpp_xml:element(?NS_ROSTER, 'query', [], []), SubelGet = exmpp_xml:element(?NS_ROSTER, 'query', [], []),
@ -497,7 +497,7 @@ extract_user_info(roster, Username, Host) ->
end; end;
extract_user_info(offline, Username, Host) -> extract_user_info(offline, Username, Host) ->
case loaded_module(Host,[mod_offline,mod_offline_odbc]) of case loaded_module(Host,[mod_offline]) of
{ok, mod_offline} -> {ok, mod_offline} ->
Els = mnesia_pop_offline_messages([], Username, Host), Els = mnesia_pop_offline_messages([], Username, Host),
case Els of case Els of
@ -508,24 +508,20 @@ extract_user_info(offline, Username, Host) ->
%OfEl = {xmlelement, "offline-messages", [], Els}, %OfEl = {xmlelement, "offline-messages", [], Els},
exmpp_xml:document_to_list(OfEl) exmpp_xml:document_to_list(OfEl)
end; end;
{ok, mod_offline_odbc} ->
"";
_E -> _E ->
"" ""
end; end;
extract_user_info(private, Username, Host) -> extract_user_info(private, Username, Host) ->
case loaded_module(Host,[mod_private,mod_private_odbc]) of case loaded_module(Host,[mod_private]) of
{ok, mod_private} -> {ok, mod_private} ->
get_user_private_mnesia(Username, Host); get_user_private_mnesia(Username, Host);
{ok, mod_private_odbc} ->
"";
_E -> _E ->
"" ""
end; end;
extract_user_info(vcard, Username, Host) -> extract_user_info(vcard, Username, Host) ->
case loaded_module(Host,[mod_vcard, mod_vcard_odbc, mod_vcard_odbc]) of case loaded_module(Host,[mod_vcard]) of
{ok, M} -> {ok, M} ->
From = To = exmpp_jid:make(Username, Host, ""), From = To = exmpp_jid:make(Username, Host, ""),
SubelGet = exmpp_xml:element(?NS_VCARD, 'vCard', [], []), SubelGet = exmpp_xml:element(?NS_VCARD, 'vCard', [], []),

View File

@ -116,7 +116,6 @@ xdb_data(_User, _Server, #xmlcdata{}) ->
ok; ok;
xdb_data(User, Server, #xmlel{ns = NS} = El) -> xdb_data(User, Server, #xmlel{ns = NS} = El) ->
From = exmpp_jid:make(User, Server), From = exmpp_jid:make(User, Server),
LServer = exmpp_stringprep:nameprep(Server),
UserB = list_to_binary(User), UserB = list_to_binary(User),
ServerB = list_to_binary(Server), ServerB = list_to_binary(Server),
case NS of case NS of
@ -125,47 +124,22 @@ xdb_data(User, Server, #xmlel{ns = NS} = El) ->
ejabberd_auth:set_password(UserB, ServerB, Password), ejabberd_auth:set_password(UserB, ServerB, Password),
ok; ok;
?NS_ROSTER -> ?NS_ROSTER ->
case lists:member(mod_roster_odbc, catch mod_roster:set_items(UserB, ServerB, El),
gen_mod:loaded_modules(LServer)) of
true ->
catch mod_roster_odbc:set_items(UserB, ServerB, El);
false ->
catch mod_roster:set_items(UserB, ServerB, El)
end,
ok; ok;
?NS_LAST_ACTIVITY -> ?NS_LAST_ACTIVITY ->
TimeStamp = exmpp_xml:get_attribute_as_list(El, 'last', ""), TimeStamp = exmpp_xml:get_attribute_as_list(El, 'last', ""),
Status = exmpp_xml:get_cdata(El), Status = exmpp_xml:get_cdata(El),
case lists:member(mod_last_odbc,
gen_mod:loaded_modules(LServer)) of
true ->
catch mod_last_odbc:store_last_info(
UserB,
ServerB,
list_to_integer(TimeStamp),
Status);
false ->
catch mod_last:store_last_info( catch mod_last:store_last_info(
UserB, UserB,
ServerB, ServerB,
list_to_integer(TimeStamp), list_to_integer(TimeStamp),
Status) Status),
end,
ok; ok;
?NS_VCARD -> ?NS_VCARD ->
case lists:member(mod_vcard_odbc,
gen_mod:loaded_modules(LServer)) of
true ->
catch mod_vcard_odbc:process_sm_iq(
From,
exmpp_jid:make(Server),
#iq{kind = request, type = set, ns = ?NS_VCARD, payload = El, iq_ns = ?NS_JABBER_CLIENT});
false ->
catch mod_vcard:process_sm_iq( catch mod_vcard:process_sm_iq(
From, From,
exmpp_jid:make(Server), exmpp_jid:make(Server),
#iq{kind = request, type = set, ns = ?NS_VCARD, payload = El, iq_ns = ?NS_JABBER_CLIENT}) #iq{kind = request, type = set, ns = ?NS_VCARD, payload = El, iq_ns = ?NS_JABBER_CLIENT}),
end,
ok; ok;
"jabber:x:offline" -> "jabber:x:offline" ->
process_offline(Server, From, El), process_offline(Server, From, El),

View File

@ -1779,12 +1779,9 @@ stop_node(From, Host, ENode, Action, XData) ->
get_last_info(User, Server) -> get_last_info(User, Server) ->
ML = lists:member(mod_last, gen_mod:loaded_modules(Server)), case lists:member(mod_last, gen_mod:loaded_modules(Server)) of
MLO = lists:member(mod_last_odbc, gen_mod:loaded_modules(Server)), true -> mod_last:get_last_info(User, Server);
case {ML, MLO} of false -> not_found
{true, _} -> mod_last:get_last_info(User, Server);
{false, true} -> mod_last_odbc:get_last_info(User, Server);
{false, false} -> not_found
end. end.

View File

@ -176,7 +176,7 @@ get_user_roster(Items, US) ->
get_vcard_module(Server) -> get_vcard_module(Server) ->
Modules = gen_mod:loaded_modules(Server), Modules = gen_mod:loaded_modules(Server),
[M || M <- Modules, [M || M <- Modules,
(M == mod_vcard) or (M == mod_vcard_odbc) or (M == mod_vcard_ldap)]. (M == mod_vcard) or (M == mod_vcard_ldap)].
get_rosteritem_name([], _, _) -> get_rosteritem_name([], _, _) ->
<<>>; <<>>;
@ -235,15 +235,14 @@ process_item(RosterItem, Host) ->
[] -> [] ->
%% Remove pending subscription by setting it %% Remove pending subscription by setting it
%% unsubscribed. %% unsubscribed.
Mod = get_roster_mod(ServerFrom),
%% Remove pending out subscription %% Remove pending out subscription
Mod:out_subscription(UserTo, ServerTo, mod_roster:out_subscription(UserTo, ServerTo,
exmpp_jid:make(UserFrom, ServerFrom), exmpp_jid:make(UserFrom, ServerFrom),
unsubscribe), unsubscribe),
%% Remove pending in subscription %% Remove pending in subscription
Mod:in_subscription(aaaa, UserFrom, ServerFrom, mod_roster:in_subscription(aaaa, UserFrom, ServerFrom,
exmpp_jid:make(UserTo, ServerTo), exmpp_jid:make(UserTo, ServerTo),
unsubscribe, ""), unsubscribe, ""),
@ -272,8 +271,6 @@ build_roster_record(User1, Server1, User2, Server2, Name2, Groups) ->
set_new_rosteritems(UserFrom, ServerFrom, set_new_rosteritems(UserFrom, ServerFrom,
UserTo, ServerTo, ResourceTo, NameTo, GroupsFrom) -> UserTo, ServerTo, ResourceTo, NameTo, GroupsFrom) ->
Mod = get_roster_mod(ServerFrom),
RIFrom = build_roster_record(UserFrom, ServerFrom, RIFrom = build_roster_record(UserFrom, ServerFrom,
UserTo, ServerTo, NameTo, GroupsFrom), UserTo, ServerTo, NameTo, GroupsFrom),
set_item(UserFrom, ServerFrom, ResourceTo, RIFrom), set_item(UserFrom, ServerFrom, ResourceTo, RIFrom),
@ -285,20 +282,20 @@ set_new_rosteritems(UserFrom, ServerFrom,
set_item(UserTo, ServerTo, undefined, RITo), set_item(UserTo, ServerTo, undefined, RITo),
%% From requests %% From requests
Mod:out_subscription(UserFrom, ServerFrom, JIDTo, subscribe), mod_roster:out_subscription(UserFrom, ServerFrom, JIDTo, subscribe),
Mod:in_subscription(aaa, UserTo, ServerTo, JIDFrom, subscribe, ""), mod_roster:in_subscription(aaa, UserTo, ServerTo, JIDFrom, subscribe, ""),
%% To accepts %% To accepts
Mod:out_subscription(UserTo, ServerTo, JIDFrom, subscribed), mod_roster:out_subscription(UserTo, ServerTo, JIDFrom, subscribed),
Mod:in_subscription(aaa, UserFrom, ServerFrom, JIDTo, subscribed, ""), mod_roster:in_subscription(aaa, UserFrom, ServerFrom, JIDTo, subscribed, ""),
%% To requests %% To requests
Mod:out_subscription(UserTo, ServerTo, JIDFrom, subscribe), mod_roster:out_subscription(UserTo, ServerTo, JIDFrom, subscribe),
Mod:in_subscription(aaa, UserFrom, ServerFrom, JIDTo, subscribe, ""), mod_roster:in_subscription(aaa, UserFrom, ServerFrom, JIDTo, subscribe, ""),
%% From accepts %% From accepts
Mod:out_subscription(UserFrom, ServerFrom, JIDTo, subscribed), mod_roster:out_subscription(UserFrom, ServerFrom, JIDTo, subscribed),
Mod:in_subscription(aaa, UserTo, ServerTo, JIDFrom, subscribed, ""), mod_roster:in_subscription(aaa, UserTo, ServerTo, JIDFrom, subscribed, ""),
RIFrom. RIFrom.
@ -370,15 +367,13 @@ in_subscription(Acc, User, Server, JID, Type, _Reason) ->
process_subscription(in, User, Server, JID, Type, Acc). process_subscription(in, User, Server, JID, Type, Acc).
out_subscription(UserFrom, ServerFrom, JIDTo, unsubscribed) -> out_subscription(UserFrom, ServerFrom, JIDTo, unsubscribed) ->
Mod = get_roster_mod(ServerFrom),
%% Remove pending out subscription %% Remove pending out subscription
{UserTo, ServerTo, _} = jlib:short_prepd_bare_jid(JIDTo), {UserTo, ServerTo, _} = jlib:short_prepd_bare_jid(JIDTo),
JIDFrom = exmpp_jid:make(UserFrom, UserTo), JIDFrom = exmpp_jid:make(UserFrom, UserTo),
Mod:out_subscription(UserTo, ServerTo, JIDFrom, unsubscribe), mod_roster:out_subscription(UserTo, ServerTo, JIDFrom, unsubscribe),
%% Remove pending in subscription %% Remove pending in subscription
Mod:in_subscription(aaaa, UserFrom, ServerFrom, JIDTo, unsubscribe, ""), mod_roster:in_subscription(aaaa, UserFrom, ServerFrom, JIDTo, unsubscribe, ""),
process_subscription(out, UserFrom, ServerFrom, JIDTo, unsubscribed, false); process_subscription(out, UserFrom, ServerFrom, JIDTo, unsubscribed, false);
out_subscription(User, Server, JID, Type) -> out_subscription(User, Server, JID, Type) ->
@ -1010,14 +1005,6 @@ shared_roster_group_parse_query(Host, Group, Query) ->
nothing nothing
end. end.
%% Get the roster module for Server.
get_roster_mod(Server) ->
case lists:member(mod_roster_odbc,
gen_mod:loaded_modules(Server)) of
true -> mod_roster_odbc;
false -> mod_roster
end.
get_opt(Opts, Opt, Default) -> get_opt(Opts, Opt, Default) ->
case lists:keysearch(Opt, 1, Opts) of case lists:keysearch(Opt, 1, Opts) of
{value, {_, Val}} -> {value, {_, Val}} ->

View File

@ -1604,7 +1604,6 @@ list_users_in_diapason(Host, Diap, Lang, URLFunc) ->
[list_given_users(Host, Sub, "../../", Lang, URLFunc)]. [list_given_users(Host, Sub, "../../", Lang, URLFunc)].
list_given_users(Host, Users, Prefix, Lang, URLFunc) -> list_given_users(Host, Users, Prefix, Lang, URLFunc) ->
ModLast = get_lastactivity_module(Host),
ModOffline = get_offlinemsg_module(Host), ModOffline = get_offlinemsg_module(Host),
?XE('table', ?XE('table',
[?XE('thead', [?XE('thead',
@ -1625,7 +1624,7 @@ list_given_users(Host, Users, Prefix, Lang, URLFunc) ->
FLast = FLast =
case ejabberd_sm:get_user_resources(UserB, ServerB) of case ejabberd_sm:get_user_resources(UserB, ServerB) of
[] -> [] ->
case ModLast:get_last_info(User, Server) of case mod_last:get_last_info(User, Server) of
not_found -> not_found ->
?T("Never"); ?T("Never");
{ok, Shift, _Status} -> {ok, Shift, _Status} ->
@ -1660,22 +1659,9 @@ get_offlinemsg_length(ModOffline, User, Server) ->
end. end.
get_offlinemsg_module(Server) -> get_offlinemsg_module(Server) ->
case [mod_offline, mod_offline_odbc] -- gen_mod:loaded_modules(Server) of case [mod_offline] -- gen_mod:loaded_modules(Server) of
[mod_offline, mod_offline_odbc] -> none; [mod_offline] -> none;
[mod_offline_odbc] -> mod_offline; [] -> mod_offline
[mod_offline] -> mod_offline_odbc
end.
get_lastactivity_module(Server) ->
case lists:member(mod_last, gen_mod:loaded_modules(Server)) of
true -> mod_last;
_ -> mod_last_odbc
end.
get_lastactivity_menuitem_list(Server) ->
case get_lastactivity_module(Server) of
mod_last -> [{"last-activity", "Last Activity"}];
mod_last_odbc -> []
end. end.
us_to_list({User, Server}) -> us_to_list({User, Server}) ->
@ -1776,10 +1762,9 @@ user_info(User, Server, Query, Lang) ->
UserItems = ejabberd_hooks:run_fold(webadmin_user, list_to_binary(LServer), [], UserItems = ejabberd_hooks:run_fold(webadmin_user, list_to_binary(LServer), [],
[User, Server, Lang]), [User, Server, Lang]),
%% Code copied from list_given_users/5: %% Code copied from list_given_users/5:
ModLast = get_lastactivity_module(Server),
LastActivity = case ejabberd_sm:get_user_resources(UserB, ServerB) of LastActivity = case ejabberd_sm:get_user_resources(UserB, ServerB) of
[] -> [] ->
case ModLast:get_last_info(UserB, ServerB) of case mod_last:get_last_info(UserB, ServerB) of
not_found -> not_found ->
?T("Never"); ?T("Never");
{ok, Shift, _Status} -> {ok, Shift, _Status} ->
@ -2963,9 +2948,9 @@ make_host_menu(Host, HostNodeMenu, Lang, JID) ->
HostFixed = [{"acls", "Access Control Lists"}, HostFixed = [{"acls", "Access Control Lists"},
{"access", "Access Rules"}, {"access", "Access Rules"},
{"users", "Users"}, {"users", "Users"},
{"online-users", "Online Users"}] {"online-users", "Online Users"},
++ get_lastactivity_menuitem_list(Host) ++ {"last-activity", "Last Activity"},
[{"nodes", "Nodes", HostNodeMenu}, {"nodes", "Nodes", HostNodeMenu},
{"misc", "Miscelanea Options"}, {"misc", "Miscelanea Options"},
{"stats", "Statistics"}] {"stats", "Statistics"}]
++ get_menu_items_hook({host, Host}, Lang), ++ get_menu_items_hook({host, Host}, Lang),