]> granicus.if.org Git - ejabberd/commitdiff
* src/mod_roster_odbc.erl: Bugfix
authorAlexey Shchepin <alexey@process-one.net>
Tue, 24 Jan 2006 21:47:53 +0000 (21:47 +0000)
committerAlexey Shchepin <alexey@process-one.net>
Tue, 24 Jan 2006 21:47:53 +0000 (21:47 +0000)
SVN Revision: 490

ChangeLog
src/mod_roster_odbc.erl

index f163feb2d5addfeee1a86645ac11f2c1ddd9276c..4d9262994e4b0dc8f60b3601124d32d91af9c3d4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2006-01-24  Alexey Shchepin  <alexey@sevcom.net>
+
+       * src/mod_roster_odbc.erl: Bugfix
+
 2006-01-23  Alexey Shchepin  <alexey@sevcom.net>
 
        * src/ejabberd_sm.erl: Partially rewritten to work more
index be4392e2eeb612992502011c61e02ef18b3cc5f4..1748d16dc47cd1a5f81721d0c47584b6e4a8292e 100644 (file)
@@ -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