@@ -584,30 +584,47 @@ do_check_packet(#jid{luser = LUser, lserver = LServer}, List, Packet, Dir) ->
584
584
roster_get_jid_info , LServer ,
585
585
{none , none , []},
586
586
[LUser , LServer , LJID ]),
587
- check_packet_aux (List , PType2 , LJID , Subscription , Groups )
587
+ {Action , _Order } = check_packet_aux (allow , last , List , PType2 , LJID ,
588
+ Subscription , Groups ),
589
+ Action
588
590
end .
589
591
590
- -spec check_packet_aux ([listitem ()],
592
+ -spec check_packet_aux (allow | deny , last | integer (), [listitem ()],
591
593
message | iq | presence_in | presence_out | other ,
592
594
ljid (), none | both | from | to , [binary ()]) ->
593
595
allow | deny .
594
596
% % Ptype = mesage | iq | presence_in | presence_out | other
595
- check_packet_aux ([], _PType , _JID , _Subscription ,
597
+ check_packet_aux (Lastaction , Lastorder , [], _PType , _JID , _Subscription ,
596
598
_Groups ) ->
597
- allow ;
598
- check_packet_aux ([Item | List ], PType , JID ,
599
+ ? DEBUG (" Finally: ~p " , [{Lastaction , Lastorder }]),
600
+ {Lastaction , Lastorder };
601
+ check_packet_aux (Lastaction , Lastorder , [Item | List ], PType , JID ,
599
602
Subscription , Groups ) ->
600
- # listitem {type = Type , value = Value , action = Action } =
603
+ ? DEBUG (" Check packet ~p against rule ~p , previously ~p " ,
604
+ [{PType , JID , Subscription , Groups }, Item , {Lastaction , Lastorder }]),
605
+ # listitem {type = Type , value = Value , action = Action , order = Order } =
601
606
Item ,
602
- case is_ptype_match (Item , PType ) of
603
- true ->
604
- case is_type_match (Type , Value , JID , Subscription , Groups ) of
605
- true -> Action ;
606
- false ->
607
- check_packet_aux (List , PType , JID , Subscription , Groups )
608
- end ;
609
- false ->
610
- check_packet_aux (List , PType , JID , Subscription , Groups )
607
+ Higherprio = case Lastorder of
608
+ last -> true ;
609
+ _ when Lastorder > Order -> true ;
610
+ _ -> false
611
+ end ,
612
+ ? DEBUG (" Higher priority rule? ~p " , [Higherprio ]),
613
+ case Higherprio of
614
+ true ->
615
+ Ptypematch = is_ptype_match (Item , PType ),
616
+ Typematch = is_type_match (Type , Value , JID , Subscription , Groups ),
617
+ ? DEBUG (" ptype match? ~p , type match? ~p " , [Ptypematch , Typematch ]),
618
+ case Ptypematch and Typematch of
619
+ true ->
620
+ ? DEBUG (" Using action ~p from this rule" , [Action ]),
621
+ check_packet_aux (Action , Order , List , PType , JID ,
622
+ Subscription , Groups );
623
+ false -> check_packet_aux (Lastaction , Lastorder , List ,
624
+ PType , JID , Subscription , Groups )
625
+ end ;
626
+ false -> check_packet_aux (Lastaction , Lastorder , List , PType , JID ,
627
+ Subscription , Groups )
611
628
end .
612
629
613
630
-spec is_ptype_match (listitem (),
0 commit comments