Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexey Shchepin <alexey@process-one.net>2006-01-25 00:47:53 +0300
committerAlexey Shchepin <alexey@process-one.net>2006-01-25 00:47:53 +0300
commitef0b3ab24c1fef9fff0e1058ce29166969a25c20 (patch)
tree108d42eeb091428f21d5f96a4ab070de2059a32b /src
parent2d7fbf3964e5a152e84031a5e6c79ac9ec38aeea (diff)
* src/mod_roster_odbc.erl: Bugfix
SVN Revision: 490
Diffstat (limited to 'src')
-rw-r--r--src/mod_roster_odbc.erl44
1 files changed, 15 insertions, 29 deletions
diff --git a/src/mod_roster_odbc.erl b/src/mod_roster_odbc.erl
index be4392e2e..1748d16dc 100644
--- a/src/mod_roster_odbc.erl
+++ b/src/mod_roster_odbc.erl
@@ -108,9 +108,22 @@ process_local_iq(From, To, #iq{type = Type} = IQ) ->
-process_iq_get(From, _To, #iq{sub_el = SubEl} = IQ) ->
+process_iq_get(From, To, #iq{sub_el = SubEl} = IQ) ->
LUser = From#jid.luser,
LServer = From#jid.lserver,
+ US = {LUser, LServer},
+ case catch ejabberd_hooks:run_fold(roster_get, To#jid.lserver, [], [US]) of
+ Items when is_list(Items) ->
+ XItems = lists:map(fun item_to_xml/1, Items),
+ IQ#iq{type = result,
+ sub_el = [{xmlelement, "query",
+ [{"xmlns", ?NS_ROSTER}],
+ XItems}]};
+ _ ->
+ IQ#iq{type = error, sub_el = [SubEl, ?ERR_INTERNAL_SERVER_ERROR]}
+ end.
+
+get_user_roster(Acc, {LUser, LServer}) ->
Username = ejabberd_odbc:escape(LUser),
case catch ejabberd_odbc:sql_query(
LServer,
@@ -130,7 +143,7 @@ process_iq_get(From, _To, #iq{sub_el = SubEl} = IQ) ->
_ ->
[]
end,
- XItems = lists:flatmap(
+ RItems = lists:flatmap(
fun(I) ->
case raw_to_record(I) of
error ->
@@ -146,33 +159,6 @@ process_iq_get(From, _To, #iq{sub_el = SubEl} = IQ) ->
[item_to_xml(R#roster{groups = Groups})]
end
end, Items),
- IQ#iq{type = result,
- sub_el = [{xmlelement, "query",
- [{"xmlns", ?NS_ROSTER}],
- XItems}]};
- _ ->
- IQ#iq{type = error, sub_el = [SubEl, ?ERR_INTERNAL_SERVER_ERROR]}
- end.
-
-get_user_roster(Acc, {LUser, LServer}) ->
- Username = ejabberd_odbc:escape(LUser),
- case catch ejabberd_odbc:sql_query(
- LServer,
- ["select username, jid, nick, subscription, ask, "
- "server, subscribe, type from rosterusers "
- "where username='", Username, "'"]) of
- {selected, ["username", "jid", "nick", "subscription", "ask",
- "server", "subscribe", "type"],
- Items} when is_list(Items) ->
- RItems = lists:flatmap(
- fun(I) ->
- case raw_to_record(I) of
- error ->
- [];
- R ->
- [R]
- end
- end, Items),
RItems ++ Acc;
_ ->
Acc