-
Notifications
You must be signed in to change notification settings - Fork 56
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
Don't require end
on /messages
#1265
Changes from 3 commits
d8d4822
3725349
1b316f7
6ccdc6b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -136,15 +136,15 @@ sub matrix_send_room_text_message | |||||
|
||||||
check => sub { | ||||||
my ( $user, $room_id ) = @_; | ||||||
my $token; | ||||||
|
||||||
matrix_send_room_text_message_synced( $user, $room_id, | ||||||
body => "Here is the message content", | ||||||
)->then( sub { | ||||||
matrix_sync( $user ) | ||||||
})->then( sub { | ||||||
my ( $sync_body ) = @_; | ||||||
my $token = $sync_body->{rooms}->{join}->{$room_id}->{timeline}->{prev_batch}; | ||||||
|
||||||
$token = $sync_body->{rooms}->{join}->{$room_id}->{timeline}->{prev_batch}; | ||||||
do_request_json_for( $user, | ||||||
method => "GET", | ||||||
uri => "/v3/rooms/$room_id/messages", | ||||||
|
@@ -158,12 +158,33 @@ sub matrix_send_room_text_message | |||||
})->then( sub { | ||||||
my ( $body ) = @_; | ||||||
|
||||||
# We should still get events and a "end" key, check it is actually there | ||||||
assert_json_keys( $body, qw( start end chunk )); | ||||||
assert_json_list( $body->{chunk} ); | ||||||
$token = $body->{end}; | ||||||
|
||||||
scalar @{ $body->{chunk} } > 0 or | ||||||
die "Expected some messages but got none at all\n"; | ||||||
})->then( sub { | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
# Do another call to /messages, this time we don't expect to receive a "end" key | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
do_request_json_for( $user, | ||||||
method => "GET", | ||||||
uri => "/v3/rooms/$room_id/messages", | ||||||
|
||||||
# With no params this does "forwards from END"; i.e. nothing useful | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this needs repeating here
Suggested change
|
||||||
params => { | ||||||
dir => "b", | ||||||
from => $token, | ||||||
}, | ||||||
) | ||||||
})->then( sub { | ||||||
my ( $body ) = @_; | ||||||
|
||||||
assert_json_keys( $body, qw( start chunk )); | ||||||
if( exists $body->{end} ) { | ||||||
die "Unexpected 'end' key in response" | ||||||
} | ||||||
Future->done(1); | ||||||
}); | ||||||
}; | ||||||
|
@@ -174,14 +195,15 @@ sub matrix_send_room_text_message | |||||
|
||||||
check => sub { | ||||||
my ( $user, $room_id ) = @_; | ||||||
my $token; | ||||||
|
||||||
matrix_send_room_text_message_synced( $user, $room_id, | ||||||
body => "Here is the message content", | ||||||
)->then( sub { | ||||||
matrix_sync( $user ) | ||||||
})->then( sub { | ||||||
my ( $sync_body ) = @_; | ||||||
my $token = $sync_body->{rooms}->{join}->{$room_id}->{timeline}->{prev_batch}; | ||||||
$token = $sync_body->{rooms}->{join}->{$room_id}->{timeline}->{prev_batch}; | ||||||
|
||||||
do_request_json_for( $user, | ||||||
method => "GET", | ||||||
|
@@ -197,10 +219,12 @@ sub matrix_send_room_text_message | |||||
my ( $body ) = @_; | ||||||
|
||||||
log_if_fail "Body", $body; | ||||||
|
||||||
|
||||||
# We should still get events and a "end" key, check it is actually there | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
assert_json_keys( $body, qw( start end state chunk )); | ||||||
assert_json_list( $body->{chunk} ); | ||||||
assert_json_list( $body->{state} ); | ||||||
$token = $body->{end}; | ||||||
|
||||||
assert_eq( scalar @{$body->{state}}, 1); | ||||||
assert_eq( $body->{state}[0]{type}, 'm.room.member'); | ||||||
|
@@ -209,6 +233,25 @@ sub matrix_send_room_text_message | |||||
scalar @{ $body->{chunk} } > 0 or | ||||||
die "Expected some messages but got none at all\n"; | ||||||
|
||||||
})->then( sub { | ||||||
# Do another call to /messages, this time we don't expect to receive a "end" key | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
do_request_json_for( $user, | ||||||
method => "GET", | ||||||
uri => "/v3/rooms/$room_id/messages", | ||||||
|
||||||
# With no params this does "forwards from END"; i.e. nothing useful | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
params => { | ||||||
dir => "b", | ||||||
from => $token, | ||||||
}, | ||||||
) | ||||||
})->then( sub { | ||||||
my ( $body ) = @_; | ||||||
|
||||||
assert_json_keys( $body, qw( start chunk )); | ||||||
if( exists $body->{end} ) { | ||||||
die "Unexpected 'end' key in response" | ||||||
} | ||||||
Future->done(1); | ||||||
}); | ||||||
}; | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.