Skip to content

Commit

Permalink
Correctly parse requesting all boxes
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonVides committed Mar 31, 2022
1 parent 2dedbcb commit 7857006
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 11 additions & 0 deletions big_tests/tests/inbox_extensions_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ groups() ->
box_full_archive_can_be_fetched_queryid,
box_and_archive_box_has_preference,
box_other_does_get_fetched,
box_all_full_fetch,
% archive
archive_active_entry_gets_archived,
archive_archived_entry_gets_active_on_request,
Expand Down Expand Up @@ -417,6 +418,16 @@ box_other_does_get_fetched(Config) ->
inbox_helper:check_inbox(Bob, [], #{box => archive})
end).

box_all_full_fetch(Config) ->
escalus:fresh_story(Config, [{alice, 1}, {bob, 1}, {kate, 1}], fun(Alice, Bob, Kate) ->
% Alice sends a message to Bob and Kate
#{ Alice := AliceConvs } = inbox_helper:given_conversations_between(Alice, [Bob, Kate]),
inbox_helper:check_inbox(Alice, AliceConvs),
set_inbox_properties(Alice, Bob, [{box, archive}]),
set_inbox_properties(Alice, Kate, [{box, other}]),
inbox_helper:check_inbox(Alice, AliceConvs, #{box => all})
end).

% archive
archive_active_entry_gets_archived(Config) ->
escalus:fresh_story(Config, [{alice, 1}, {bob, 1}], fun(Alice, Bob) ->
Expand Down
6 changes: 4 additions & 2 deletions src/inbox/mod_inbox.erl
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,9 @@ fields_to_params(HostType, [{<<"box">>, [Value]} | RFields], Acc) ->
?LOG_WARNING(#{what => inbox_invalid_form_field,
field => box, value => Value}),
{error, bad_request, invalid_field_value(<<"box">>, Value)};
true ->
<<"all">> ->
fields_to_params(HostType, RFields, Acc);
_ ->
fields_to_params(HostType, RFields, Acc#{ box => Value })
end;

Expand All @@ -514,7 +516,7 @@ binary_to_order(_) -> error.

validate_box(HostType, Box) ->
AllBoxes = mod_inbox_utils:all_valid_boxes_for_query(HostType),
lists:member(Box, AllBoxes).
lists:member(Box, AllBoxes) andalso Box.

invalid_field_value(Field, Value) ->
<<"Invalid inbox form field value, field=", Field/binary, ", value=", Value/binary>>.
Expand Down

0 comments on commit 7857006

Please sign in to comment.