Skip to content

Commit

Permalink
mod_privacy: honor the 'order' attribute
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
crosser committed Jul 15, 2018
1 parent 2dfb5a6 commit dc9d46d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/mod_privacy.erl
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,15 @@ do_check_packet(#jid{luser = LUser, lserver = LServer}, List, Packet, Dir) ->
roster_get_jid_info, LServer,
{none, none, []},
[LUser, LServer, LJID]),
check_packet_aux(List, PType2, LJID, Subscription, Groups)
check_packet_aux(reorder(List), PType2, LJID, Subscription, Groups)
end.

-spec compare_order(listitem(), listitem()) -> boolean().
compare_order(#listitem{order = Ord1}, #listitem{order = Ord2}) -> Ord1 < Ord2.

-spec reorder([listitem()]) -> [listitem()].
reorder(List) -> lists:sort(compare_order, List).

-spec check_packet_aux([listitem()],
message | iq | presence_in | presence_out | other,
ljid(), none | both | from | to, [binary()]) ->
Expand Down

0 comments on commit dc9d46d

Please sign in to comment.