25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

Prevent case_clause error when ejabber_odbc:sql_query returns {error, Reason}

SVN Revision: 1538
This commit is contained in:
Christophe Romain 2008-08-25 13:12:23 +00:00
parent 2d226b39bf
commit 5c9069d677
3 changed files with 33 additions and 25 deletions

View File

@ -1,3 +1,9 @@
2008-08-25 Christophe Romain <christophe.romain@process-one.net>
* src/mod_privacy_odbc.erl: Prevent case_clause error when
ejabber_odbc:sql_query returns {error, Reason}
* src/mod_vcard_odbc.erl: Likewise
2008-08-25 Badlop <badlop@process-one.net> 2008-08-25 Badlop <badlop@process-one.net>
* src/ejabberd_check.erl: Detect correctly MSSQL and ODBC * src/ejabberd_check.erl: Detect correctly MSSQL and ODBC

View File

@ -96,16 +96,14 @@ process_iq_get(_, From, _To, #iq{sub_el = SubEl},
process_lists_get(LUser, LServer, Active) -> process_lists_get(LUser, LServer, Active) ->
Default = case catch sql_get_default_privacy_list(LUser, LServer) of Default = case catch sql_get_default_privacy_list(LUser, LServer) of
{'EXIT', _Reason} ->
none;
{selected, ["name"], []} -> {selected, ["name"], []} ->
none; none;
{selected, ["name"], [{DefName}]} -> {selected, ["name"], [{DefName}]} ->
DefName DefName;
_ ->
none
end, end,
case catch sql_get_privacy_list_names(LUser, LServer) of case catch sql_get_privacy_list_names(LUser, LServer) of
{'EXIT', _Reason2} ->
{error, ?ERR_INTERNAL_SERVER_ERROR};
{selected, ["name"], []} -> {selected, ["name"], []} ->
{result, [{xmlelement, "query", [{"xmlns", ?NS_PRIVACY}], []}]}; {result, [{xmlelement, "query", [{"xmlns", ?NS_PRIVACY}], []}]};
{selected, ["name"], Names} -> {selected, ["name"], Names} ->
@ -132,19 +130,17 @@ process_lists_get(LUser, LServer, Active) ->
end, end,
{result, {result,
[{xmlelement, "query", [{"xmlns", ?NS_PRIVACY}], [{xmlelement, "query", [{"xmlns", ?NS_PRIVACY}],
ADItems}]} ADItems}]};
_ ->
{error, ?ERR_INTERNAL_SERVER_ERROR}
end. end.
process_list_get(LUser, LServer, {value, Name}) -> process_list_get(LUser, LServer, {value, Name}) ->
case catch sql_get_privacy_list_id(LUser, LServer, Name) of case catch sql_get_privacy_list_id(LUser, LServer, Name) of
{'EXIT', _Reason} ->
{error, ?ERR_INTERNAL_SERVER_ERROR};
{selected, ["id"], []} -> {selected, ["id"], []} ->
{error, ?ERR_ITEM_NOT_FOUND}; {error, ?ERR_ITEM_NOT_FOUND};
{selected, ["id"], [{ID}]} -> {selected, ["id"], [{ID}]} ->
case catch sql_get_privacy_list_data_by_id(ID, LServer) of case catch sql_get_privacy_list_data_by_id(ID, LServer) of
{'EXIT', _Reason} ->
{error, ?ERR_INTERNAL_SERVER_ERROR};
{selected, ["t", "value", "action", "ord", "match_all", {selected, ["t", "value", "action", "ord", "match_all",
"match_iq", "match_message", "match_iq", "match_message",
"match_presence_in", "match_presence_out"], "match_presence_in", "match_presence_out"],
@ -154,8 +150,12 @@ process_list_get(LUser, LServer, {value, Name}) ->
{result, {result,
[{xmlelement, "query", [{"xmlns", ?NS_PRIVACY}], [{xmlelement, "query", [{"xmlns", ?NS_PRIVACY}],
[{xmlelement, "list", [{xmlelement, "list",
[{"name", Name}], LItems}]}]} [{"name", Name}], LItems}]}]};
end _ ->
{error, ?ERR_INTERNAL_SERVER_ERROR}
end;
_ ->
{error, ?ERR_INTERNAL_SERVER_ERROR}
end; end;
process_list_get(_LUser, _LServer, false) -> process_list_get(_LUser, _LServer, false) ->
@ -294,6 +294,8 @@ process_default_set(LUser, LServer, false) ->
case catch sql_unset_default_privacy_list(LUser, LServer) of case catch sql_unset_default_privacy_list(LUser, LServer) of
{'EXIT', _Reason} -> {'EXIT', _Reason} ->
{error, ?ERR_INTERNAL_SERVER_ERROR}; {error, ?ERR_INTERNAL_SERVER_ERROR};
{error, _Reason} ->
{error, ?ERR_INTERNAL_SERVER_ERROR};
_ -> _ ->
{result, []} {result, []}
end. end.
@ -301,21 +303,21 @@ process_default_set(LUser, LServer, false) ->
process_active_set(LUser, LServer, {value, Name}) -> process_active_set(LUser, LServer, {value, Name}) ->
case catch sql_get_privacy_list_id(LUser, LServer, Name) of case catch sql_get_privacy_list_id(LUser, LServer, Name) of
{'EXIT', _Reason} ->
{error, ?ERR_INTERNAL_SERVER_ERROR};
{selected, ["id"], []} -> {selected, ["id"], []} ->
{error, ?ERR_ITEM_NOT_FOUND}; {error, ?ERR_ITEM_NOT_FOUND};
{selected, ["id"], [{ID}]} -> {selected, ["id"], [{ID}]} ->
case catch sql_get_privacy_list_data_by_id(ID, LServer) of case catch sql_get_privacy_list_data_by_id(ID, LServer) of
{'EXIT', _Reason} ->
{error, ?ERR_INTERNAL_SERVER_ERROR};
{selected, ["t", "value", "action", "ord", "match_all", {selected, ["t", "value", "action", "ord", "match_all",
"match_iq", "match_message", "match_iq", "match_message",
"match_presence_in", "match_presence_out"], "match_presence_in", "match_presence_out"],
RItems} -> RItems} ->
Items = lists:map(fun raw_to_item/1, RItems), Items = lists:map(fun raw_to_item/1, RItems),
{result, [], #userlist{name = Name, list = Items}} {result, [], #userlist{name = Name, list = Items}};
end _ ->
{error, ?ERR_INTERNAL_SERVER_ERROR}
end;
_ ->
{error, ?ERR_INTERNAL_SERVER_ERROR}
end; end;
process_active_set(_LUser, _LServer, false) -> process_active_set(_LUser, _LServer, false) ->
@ -517,21 +519,21 @@ get_user_list(_, User, Server) ->
LServer = jlib:nameprep(Server), LServer = jlib:nameprep(Server),
case catch sql_get_default_privacy_list(LUser, LServer) of case catch sql_get_default_privacy_list(LUser, LServer) of
{'EXIT', _Reason} ->
#userlist{};
{selected, ["name"], []} -> {selected, ["name"], []} ->
#userlist{}; #userlist{};
{selected, ["name"], [{Default}]} -> {selected, ["name"], [{Default}]} ->
case catch sql_get_privacy_list_data(LUser, LServer, Default) of case catch sql_get_privacy_list_data(LUser, LServer, Default) of
{'EXIT', _Reason} ->
#userlist{};
{selected, ["t", "value", "action", "ord", "match_all", {selected, ["t", "value", "action", "ord", "match_all",
"match_iq", "match_message", "match_iq", "match_message",
"match_presence_in", "match_presence_out"], "match_presence_in", "match_presence_out"],
RItems} -> RItems} ->
Items = lists:map(fun raw_to_item/1, RItems), Items = lists:map(fun raw_to_item/1, RItems),
#userlist{name = Default, list = Items} #userlist{name = Default, list = Items};
end _ ->
#userlist{}
end;
_ ->
#userlist{}
end. end.

View File

@ -162,7 +162,7 @@ process_sm_iq(From, To, #iq{type = Type, sub_el = SubEl} = IQ) ->
end; end;
{selected, ["vcard"], []} -> {selected, ["vcard"], []} ->
IQ#iq{type = result, sub_el = []}; IQ#iq{type = result, sub_el = []};
{'EXIT', _Reason} -> _ ->
IQ#iq{type = error, IQ#iq{type = error,
sub_el = [SubEl, ?ERR_INTERNAL_SERVER_ERROR]} sub_el = [SubEl, ?ERR_INTERNAL_SERVER_ERROR]}
end end