Skip to content

Commit dc9d46d

Browse files
committed
mod_privacy: honor the 'order' attribute
When checking a packet against the active privacy list, make sure that the items in the list are sorted according to the 'order' attribute. Bug-url: #2529 Signed-off-by: Eugene Crosser <crosser@average.org>
1 parent 2dfb5a6 commit dc9d46d

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/mod_privacy.erl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,9 +584,15 @@ do_check_packet(#jid{luser = LUser, lserver = LServer}, List, Packet, Dir) ->
584584
roster_get_jid_info, LServer,
585585
{none, none, []},
586586
[LUser, LServer, LJID]),
587-
check_packet_aux(List, PType2, LJID, Subscription, Groups)
587+
check_packet_aux(reorder(List), PType2, LJID, Subscription, Groups)
588588
end.
589589

590+
-spec compare_order(listitem(), listitem()) -> boolean().
591+
compare_order(#listitem{order = Ord1}, #listitem{order = Ord2}) -> Ord1 < Ord2.
592+
593+
-spec reorder([listitem()]) -> [listitem()].
594+
reorder(List) -> lists:sort(compare_order, List).
595+
590596
-spec check_packet_aux([listitem()],
591597
message | iq | presence_in | presence_out | other,
592598
ljid(), none | both | from | to, [binary()]) ->

0 commit comments

Comments
 (0)