Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route pagination requests to client reader #628

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/SyTest/Homeserver/Synapse.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,8 @@ sub generate_haproxy_map
^/_matrix/federation/v1/get_missing_events/ federation_reader
^/_matrix/federation/v1/publicRooms federation_reader

^/_matrix/client/(api/v1|r0)/publicRooms$ client_reader
^/_matrix/client/(api/v1|r0)/publicRooms$ client_reader
^/_matrix/client/(api/v1|r0)/rooms/.*/messages$ client_reader

^/_matrix/client/(r0|unstable|v2_alpha)/user_directory/ user_dir

Expand Down
36 changes: 36 additions & 0 deletions tests/30rooms/04messages.pl
Original file line number Diff line number Diff line change
Expand Up @@ -352,3 +352,39 @@
})
});
};


test "/messages does not require a from param",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right now, the fact that synapse doesn't return a 400 when this happens is a synapse bug. If we want to go the other way, it'll need an MSC defining what it means to not give a from param...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh. Ok, I just wanted a regression test but it doesn't seem obvious to me we should support not supplying a from

requires => [ magic_local_user_and_room_fixtures() ],

proves => [qw( can_paginate_room )],

do => sub {
my ( $user, $room_id ) = @_;

( repeat {
matrix_send_room_text_message( $user, $room_id,
body => "Message number $_[0]"
)
} foreach => [ 1 .. 5 ] )->then( sub {
do_request_json_for( $user,
method => "GET",
uri => "/r0/rooms/$room_id/messages",
params => {
dir => "b",
},
);
})->then( sub {
my ( $body ) = @_;
log_if_fail "First messages body", $body;

my $chunk = $body->{chunk};
@$chunk > 0 or
die "Expected messages";

assert_eq( $chunk->[0]{content}{body}, "Message number 5",
'chunk[0] content body' );

Future->done(1);
});
};