mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-28 16:34:13 +01:00
Don't crash when exporting a module that is not enabled
This commit is contained in:
parent
cfc393a12e
commit
ceeba3eea1
@ -214,26 +214,30 @@ parse_scram_password(PassData) ->
|
|||||||
get_vcard(User, Server) ->
|
get_vcard(User, Server) ->
|
||||||
LUser = jid:nodeprep(User),
|
LUser = jid:nodeprep(User),
|
||||||
LServer = jid:nameprep(Server),
|
LServer = jid:nameprep(Server),
|
||||||
case mod_vcard:get_vcard(LUser, LServer) of
|
try mod_vcard:get_vcard(LUser, LServer) of
|
||||||
error -> [];
|
error -> [];
|
||||||
Els -> Els
|
Els -> Els
|
||||||
|
catch
|
||||||
|
error:{module_not_loaded, _, _} -> []
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec get_offline(binary(), binary()) -> [xmlel()].
|
-spec get_offline(binary(), binary()) -> [xmlel()].
|
||||||
get_offline(User, Server) ->
|
get_offline(User, Server) ->
|
||||||
LUser = jid:nodeprep(User),
|
LUser = jid:nodeprep(User),
|
||||||
LServer = jid:nameprep(Server),
|
LServer = jid:nameprep(Server),
|
||||||
case mod_offline:get_offline_els(LUser, LServer) of
|
try mod_offline:get_offline_els(LUser, LServer) of
|
||||||
[] ->
|
[] ->
|
||||||
[];
|
[];
|
||||||
Els ->
|
Els ->
|
||||||
NewEls = lists:map(fun xmpp:encode/1, Els),
|
NewEls = lists:map(fun xmpp:encode/1, Els),
|
||||||
[#xmlel{name = <<"offline-messages">>, children = NewEls}]
|
[#xmlel{name = <<"offline-messages">>, children = NewEls}]
|
||||||
|
catch
|
||||||
|
error:{module_not_loaded, _, _} -> []
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec get_privacy(binary(), binary()) -> [xmlel()].
|
-spec get_privacy(binary(), binary()) -> [xmlel()].
|
||||||
get_privacy(User, Server) ->
|
get_privacy(User, Server) ->
|
||||||
case mod_privacy:get_user_lists(User, Server) of
|
try mod_privacy:get_user_lists(User, Server) of
|
||||||
{ok, #privacy{default = Default,
|
{ok, #privacy{default = Default,
|
||||||
lists = [_|_] = Lists}} ->
|
lists = [_|_] = Lists}} ->
|
||||||
XLists = lists:map(
|
XLists = lists:map(
|
||||||
@ -246,12 +250,14 @@ get_privacy(User, Server) ->
|
|||||||
[xmpp:encode(#privacy_query{default = Default, lists = XLists})];
|
[xmpp:encode(#privacy_query{default = Default, lists = XLists})];
|
||||||
_ ->
|
_ ->
|
||||||
[]
|
[]
|
||||||
|
catch
|
||||||
|
error:{module_not_loaded, _, _} -> []
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec get_roster(binary(), binary()) -> [xmlel()].
|
-spec get_roster(binary(), binary()) -> [xmlel()].
|
||||||
get_roster(User, Server) ->
|
get_roster(User, Server) ->
|
||||||
JID = jid:make(User, Server),
|
JID = jid:make(User, Server),
|
||||||
case mod_roster:get_roster(User, Server) of
|
try mod_roster:get_roster(User, Server) of
|
||||||
[_|_] = Items ->
|
[_|_] = Items ->
|
||||||
Subs =
|
Subs =
|
||||||
lists:flatmap(
|
lists:flatmap(
|
||||||
@ -278,15 +284,19 @@ get_roster(User, Server) ->
|
|||||||
[xmpp:encode(#roster_query{items = Rs}) | Subs];
|
[xmpp:encode(#roster_query{items = Rs}) | Subs];
|
||||||
_ ->
|
_ ->
|
||||||
[]
|
[]
|
||||||
|
catch
|
||||||
|
error:{module_not_loaded, _, _} -> []
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec get_private(binary(), binary()) -> [xmlel()].
|
-spec get_private(binary(), binary()) -> [xmlel()].
|
||||||
get_private(User, Server) ->
|
get_private(User, Server) ->
|
||||||
case mod_private:get_data(User, Server) of
|
try mod_private:get_data(User, Server) of
|
||||||
[_|_] = Els ->
|
[_|_] = Els ->
|
||||||
[xmpp:encode(#private{sub_els = Els})];
|
[xmpp:encode(#private{sub_els = Els})];
|
||||||
_ ->
|
_ ->
|
||||||
[]
|
[]
|
||||||
|
catch
|
||||||
|
error:{module_not_loaded, _, _} -> []
|
||||||
end.
|
end.
|
||||||
|
|
||||||
process(#state{xml_stream_state = XMLStreamState, fd = Fd} = State) ->
|
process(#state{xml_stream_state = XMLStreamState, fd = Fd} = State) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user