]> granicus.if.org Git - ejabberd/commitdiff
* src/ejabberd_sm.erl: Now delivering messages to all resources with
authorMickaël Rémond <mickael.remond@process-one.net>
Sun, 23 Apr 2006 09:31:54 +0000 (09:31 +0000)
committerMickaël Rémond <mickael.remond@process-one.net>
Sun, 23 Apr 2006 09:31:54 +0000 (09:31 +0000)
max equal priority when this priority is non-negative.

SVN Revision: 541

ChangeLog
src/ejabberd_sm.erl

index 96e3ee471e398d86755b92c20cebc5c49b3c1110..dbcc0fcc522bb194449cee55a34424e625915c83 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
 
        * src/msgs/fr.msg: Updated
        * src/msgs/de.msg: Updated (thanks to Nikolaus Polak)
+       * src/ejabberd_sm.erl: Now delivering messages to all resources with
+       max equal priority when this priority is non-negative.
 
 2006-04-22  Alexey Shchepin  <alexey@sevcom.net>
 
index 1127ddd09bc66e52547810b2275db65010793014..c9ed39b18222243b30f56db33450acdd86d7653d 100644 (file)
@@ -432,20 +432,29 @@ do_route(From, To, Packet) ->
 route_message(From, To, Packet) ->
     LUser = To#jid.luser,
     LServer = To#jid.lserver,
-    case catch lists:max(get_user_present_resources(LUser, LServer)) of
-       {Priority, R} when is_integer(Priority),
-                          Priority >= 0 ->
-           LResource = jlib:resourceprep(R),
-           USR = {LUser, LServer, LResource},
-           case mnesia:dirty_index_read(session, USR, #session.usr) of
-               [] ->
-                   ok;                         % Race condition
-               Ss ->
-                   Session = lists:max(Ss),
-                   Pid = element(2, Session#session.sid),
-                   ?DEBUG("sending to process ~p~n", [Pid]),
-                   Pid ! {route, From, To, Packet}
-           end;
+    PrioRes = get_user_present_resources(LUser, LServer),
+    case catch lists:max(PrioRes) of
+       {Priority, _R} when is_integer(Priority), Priority >= 0 ->
+           lists:foreach(
+             %% Route messages to all priority that equals the max, if
+             %% positive
+             fun({P, R}) when P == Priority ->
+                     LResource = jlib:resourceprep(R),
+                     USR = {LUser, LServer, LResource},
+                     case mnesia:dirty_index_read(session, USR, #session.usr) of
+                         [] ->
+                             ok;                               % Race condition
+                         Ss ->
+                             Session = lists:max(Ss),
+                             Pid = element(2, Session#session.sid),
+                             ?DEBUG("sending to process ~p~n", [Pid]),
+                             Pid ! {route, From, To, Packet}
+                     end;
+                %% Ignore other priority:
+                ({_Prio, _Res}) ->
+                     ok
+             end,
+             PrioRes);
        _ ->
            case xml:get_tag_attr_s("type", Packet) of
                "error" ->