mod_mam: Apply a few purely cosmetic changes
This commit is contained in:
parent
4db159b4fa
commit
6d38be2a75
|
@ -1020,11 +1020,10 @@ read_message(Key, Filter, Direction, mnesia) ->
|
||||||
[#mam_msg{} = Msg] ->
|
[#mam_msg{} = Msg] ->
|
||||||
case filter_message(Msg, Filter, Direction) of
|
case filter_message(Msg, Filter, Direction) of
|
||||||
pass ->
|
pass ->
|
||||||
?DEBUG("Message ~p passes filter ~p", [Msg, Filter]),
|
?DEBUG("Message ~p passes filter", [Msg]),
|
||||||
Msg;
|
Msg;
|
||||||
DropOrStop ->
|
DropOrStop ->
|
||||||
?DEBUG("Message ~p filtered: ~s (~p)", [Msg, DropOrStop,
|
?DEBUG("Message ~p filtered: ~s", [Msg, DropOrStop]),
|
||||||
Filter]),
|
|
||||||
DropOrStop
|
DropOrStop
|
||||||
end;
|
end;
|
||||||
[] -> not_found
|
[] -> not_found
|
||||||
|
@ -1052,14 +1051,9 @@ filter_message(Msg, Filter, Direction) ->
|
||||||
-spec filter_message(mam_filter_type(), mam_msg(), mam_filter(), direction())
|
-spec filter_message(mam_filter_type(), mam_msg(), mam_filter(), direction())
|
||||||
-> pass | drop | stop.
|
-> pass | drop | stop.
|
||||||
|
|
||||||
filter_message(start,
|
filter_message(start, _Msg, #mam_filter{start = undefined}, _Direction) ->
|
||||||
_Msg,
|
|
||||||
#mam_filter{start = undefined},
|
|
||||||
_Direction) ->
|
|
||||||
pass;
|
pass;
|
||||||
filter_message(start,
|
filter_message(start, #mam_msg{time = Time}, #mam_filter{start = Start},
|
||||||
#mam_msg{time = Time},
|
|
||||||
#mam_filter{start = Start},
|
|
||||||
_Direction) when Time >= Start ->
|
_Direction) when Time >= Start ->
|
||||||
pass;
|
pass;
|
||||||
filter_message(start, _Msg, _Filter, before) ->
|
filter_message(start, _Msg, _Filter, before) ->
|
||||||
|
@ -1067,14 +1061,9 @@ filter_message(start, _Msg, _Filter, before) ->
|
||||||
filter_message(start, _Msg, _Filter, aft) ->
|
filter_message(start, _Msg, _Filter, aft) ->
|
||||||
drop;
|
drop;
|
||||||
|
|
||||||
filter_message(fin,
|
filter_message(fin, _Msg, #mam_filter{fin = undefined}, _Direction) ->
|
||||||
_Msg,
|
|
||||||
#mam_filter{fin = undefined},
|
|
||||||
_Direction) ->
|
|
||||||
pass;
|
pass;
|
||||||
filter_message(fin,
|
filter_message(fin, #mam_msg{time = Time}, #mam_filter{fin = End},
|
||||||
#mam_msg{time = Time},
|
|
||||||
#mam_filter{fin = End},
|
|
||||||
_Direction) when Time =< End ->
|
_Direction) when Time =< End ->
|
||||||
pass;
|
pass;
|
||||||
filter_message(fin, _Msg, _Filter, aft) ->
|
filter_message(fin, _Msg, _Filter, aft) ->
|
||||||
|
@ -1082,15 +1071,9 @@ filter_message(fin, _Msg, _Filter, aft) ->
|
||||||
filter_message(fin, _Msg, _Filter, before) ->
|
filter_message(fin, _Msg, _Filter, before) ->
|
||||||
drop;
|
drop;
|
||||||
|
|
||||||
filter_message(with,
|
filter_message(with, _Msg, #mam_filter{with = undefined}, _Direction) ->
|
||||||
_Msg,
|
|
||||||
#mam_filter{with = undefined},
|
|
||||||
_Direction) ->
|
|
||||||
pass;
|
pass;
|
||||||
|
filter_message(with, Msg, #mam_filter{with = {_U, _S, <<"">>}} = Filter,
|
||||||
filter_message(with,
|
|
||||||
Msg,
|
|
||||||
#mam_filter{with = {_U, _S, <<"">>}} = Filter,
|
|
||||||
_Direction) ->
|
_Direction) ->
|
||||||
filter_message_with(bare, Msg, Filter);
|
filter_message_with(bare, Msg, Filter);
|
||||||
filter_message(with, Msg, Filter, _Direction) ->
|
filter_message(with, Msg, Filter, _Direction) ->
|
||||||
|
@ -1136,7 +1119,7 @@ filter_message_with(full, _Msg, _Filter) ->
|
||||||
|
|
||||||
another_message_exists(#mam_query{mam_jid = {U, S},
|
another_message_exists(#mam_query{mam_jid = {U, S},
|
||||||
direction = Direction,
|
direction = Direction,
|
||||||
filter = Filter } = Query, ID, DBType) ->
|
filter = Filter} = Query, ID, DBType) ->
|
||||||
case read_message({{U, S}, ID}, Filter, Direction, DBType) of
|
case read_message({{U, S}, ID}, Filter, Direction, DBType) of
|
||||||
#mam_msg{} ->
|
#mam_msg{} ->
|
||||||
?DEBUG("Found another message for ~s@~s: ~B", [U, S, ID]),
|
?DEBUG("Found another message for ~s@~s: ~B", [U, S, ID]),
|
||||||
|
@ -1148,13 +1131,12 @@ another_message_exists(#mam_query{mam_jid = {U, S},
|
||||||
?DEBUG("Found no other unfiltered message for ~s@~s: ~B", [U, S, ID]),
|
?DEBUG("Found no other unfiltered message for ~s@~s: ~B", [U, S, ID]),
|
||||||
false;
|
false;
|
||||||
drop ->
|
drop ->
|
||||||
NextID =
|
NextID = case Direction of
|
||||||
case Direction of
|
before ->
|
||||||
before ->
|
ID - 1;
|
||||||
ID - 1;
|
aft ->
|
||||||
aft ->
|
ID + 1
|
||||||
ID + 1
|
end,
|
||||||
end,
|
|
||||||
another_message_exists(Query, NextID, DBType)
|
another_message_exists(Query, NextID, DBType)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue