Skip to content

Commit

Permalink
search only in given host in mod_vcard_odbc and _mnesia
Browse files Browse the repository at this point in the history
  • Loading branch information
michalwski authored and Pawel Pikula committed Oct 8, 2015
1 parent 3bd5f06 commit 8d71cb2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions apps/ejabberd/src/mod_vcard_mnesia.erl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ search(VHost, Data, _Lang, DefaultReportedFields) ->

do_search(_, #vcard_search{_ = '_'}) ->
[];
do_search(VHost, MatchHead) ->
do_search(VHost, MatchHeadIn) ->
MatchHead = MatchHeadIn#vcard_search{us = {'_', VHost}},
case catch mnesia:dirty_select(vcard_search,
[{MatchHead, [], ['$_']}]) of
{'EXIT', Reason} ->
Expand Down Expand Up @@ -269,9 +270,7 @@ filter_fields([{SVar, [Val]} | Ds], Match, VHost)
LVal = stringprep:tolower(Val),
NewMatch =
case SVar of
<<"user">> ->
Host = find_my_host(VHost),
Match#vcard_search{us = {make_val(LVal), Host}};
<<"user">> -> Match#vcard_search{luser = make_val(LVal)};
<<"fn">> -> Match#vcard_search{lfn = make_val(LVal)};
<<"last">> -> Match#vcard_search{lfamily = make_val(LVal)};
<<"first">> -> Match#vcard_search{lgiven = make_val(LVal)};
Expand Down
6 changes: 3 additions & 3 deletions apps/ejabberd/src/mod_vcard_odbc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ search_fields(_VHost) ->
make_restriction_sql(LServer, Data) ->
filter_fields(Data, "", LServer).

filter_fields([], RestrictionSQL, _LServer) ->
case RestrictionSQL of
filter_fields([], RestrictionSQLIn, LServer) ->
case RestrictionSQLIn of
"" ->
"";
<<>> ->
<<>>;
_ ->
[" where ", RestrictionSQL]
[" where ", [RestrictionSQLIn, " and ", ["server = '", ejabberd_odbc:escape(LServer),"'"]]]
end;
filter_fields([{SVar, [Val]} | Ds], RestrictionSQL, LServer)
when is_binary(Val) and (Val /= <<"">>) ->
Expand Down

0 comments on commit 8d71cb2

Please sign in to comment.