-
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
Make the userdir synced not rely on being able to search for yourself #567
Changes from 8 commits
35ac361
30503fd
1b1f959
449b288
c83c24b
cf03a1a
a94fb67
bd8bd5c
b5cae5f
2202558
dbf3fb3
c81e1a0
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 |
---|---|---|
|
@@ -5,21 +5,32 @@ | |
my ( $user ) = @_; | ||
|
||
my $room_id; | ||
my $searching_user; | ||
|
||
my $displayname = generate_random_displayname(); | ||
my $searching_displayname = generate_random_displayname(); | ||
|
||
matrix_set_displayname( $user, $displayname ) | ||
->then( sub { | ||
matrix_create_user_on_server( $user->http, | ||
displayname => $searching_displayname | ||
); | ||
})->then( sub { | ||
( $searching_user ) = @_; | ||
|
||
matrix_create_room( $user, | ||
preset => "public_chat", | ||
); | ||
})->then( sub { | ||
my ( $room_id ) = @_; | ||
matrix_join_room( $searching_user, $room_id ); | ||
})->then( sub { | ||
( $room_id ) = @_; | ||
hawkowl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
repeat_until_true { | ||
do_request_json_for( $user, | ||
do_request_json_for( $searching_user, | ||
method => "POST", | ||
uri => "/unstable/user_directory/search", | ||
uri => "/r0/user_directory/search", | ||
content => { | ||
search_term => $displayname, | ||
} | ||
|
@@ -44,17 +55,22 @@ | |
my ( $user ) = @_; | ||
|
||
my $room_id; | ||
hawkowl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
my $searching_user; | ||
|
||
my $displayname = generate_random_displayname(); | ||
my $searching_displayname = generate_random_displayname(); | ||
|
||
matrix_set_displayname( $user, $displayname )->then( sub { | ||
matrix_create_user_on_server( $user->http, | ||
displayname => $searching_displayname | ||
); | ||
})->then( sub { | ||
( $searching_user ) = @_; | ||
|
||
matrix_set_displayname( $user, $displayname ) | ||
->then( sub { | ||
matrix_create_room( $user, | ||
preset => "private_chat", | ||
); | ||
})->then( sub { | ||
( $room_id ) = @_; | ||
|
||
matrix_get_user_dir_synced( $user, $displayname ); | ||
hawkowl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
})->then( sub { | ||
my ( $body ) = @_; | ||
|
@@ -384,12 +400,25 @@ | |
my ( $user ) = @_; | ||
|
||
my $room_id; | ||
my $searching_user; | ||
|
||
my $displayname = generate_random_displayname(); | ||
my $second_displayname = generate_random_displayname(); | ||
my $searching_displayname = generate_random_displayname(); | ||
|
||
matrix_set_displayname( $user, $displayname ) | ||
->then( sub { | ||
|
||
hawkowl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
matrix_create_user_on_server( $user->http, | ||
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'm not quite sure why we are creating a user that is never used here? 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. they have to join the room so that the dir is populated 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. they don't seem to join a room? |
||
displayname => $second_displayname | ||
); | ||
})->then( sub { | ||
matrix_create_user_on_server( $user->http, | ||
displayname => $searching_displayname | ||
); | ||
}) -> then( sub { | ||
( $searching_user ) = @_; | ||
|
||
log_if_fail "First displayname", $displayname; | ||
|
||
matrix_create_room( $user, | ||
|
@@ -398,6 +427,8 @@ | |
})->then( sub { | ||
( $room_id ) = @_; | ||
|
||
matrix_join_room( $searching_user, $room_id ); | ||
})->then( sub { | ||
matrix_get_user_dir_synced( $user, $displayname ); | ||
})->then( sub { | ||
my ( $body ) = @_; | ||
|
@@ -435,30 +466,43 @@ sub generate_random_displayname | |
} | ||
|
||
|
||
# Get the user direectory after a change has been made. This creates a new user | ||
# Get the user directory after a change has been made. This creates a new user | ||
hawkowl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# and then polls the user directory until we see it. This is to get around the | ||
hawkowl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# fact that the user directory gets updated asynchronously. | ||
sub matrix_get_user_dir_synced | ||
{ | ||
my ( $user, $search_term ) = @_; | ||
|
||
my $new_user; | ||
my $searching_user; | ||
my $room_id; | ||
|
||
my $random_id = join "", map { chr 65 + rand 26 } 1 .. 20; | ||
my $searching_random_id = join "", map { chr 65 + rand 26 } 1 .. 20; | ||
|
||
matrix_create_user_on_server( $user->http, | ||
displayname => $random_id | ||
)->then( sub { | ||
( $new_user ) = @_; | ||
|
||
matrix_create_user_on_server( $user->http, | ||
displayname => $searching_random_id | ||
); | ||
}) -> then( sub { | ||
( $searching_user ) = @_; | ||
|
||
matrix_create_room( $new_user, | ||
preset => "public_chat", | ||
); | ||
})->then( sub { | ||
( $room_id ) = @_; | ||
|
||
matrix_join_room( $searching_user, $room_id ); | ||
})->then( sub { | ||
repeat_until_true { | ||
do_request_json_for( $new_user, | ||
do_request_json_for( $searching_user, | ||
method => "POST", | ||
uri => "/unstable/user_directory/search", | ||
uri => "/r0/user_directory/search", | ||
content => { | ||
search_term => $random_id, | ||
} | ||
|
@@ -474,7 +518,7 @@ sub matrix_get_user_dir_synced | |
})->then( sub { | ||
do_request_json_for( $user, | ||
method => "POST", | ||
uri => "/unstable/user_directory/search", | ||
uri => "/r0/user_directory/search", | ||
content => { | ||
search_term => $search_term, | ||
} | ||
|
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.
nit: trailing commas are nice