From 2145ee19769b8160d8ab8b02d29bbe42563a627f Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sun, 19 Nov 2017 00:48:38 +0000 Subject: [PATCH] don't double-invite in sync_room_to_group.pl --- scripts/sync_room_to_group.pl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/sync_room_to_group.pl b/scripts/sync_room_to_group.pl index 3366c2c68f..92891f3d19 100755 --- a/scripts/sync_room_to_group.pl +++ b/scripts/sync_room_to_group.pl @@ -21,7 +21,10 @@ if ($room_id =~ /^#/) { } my $room_users = [ keys %{decode_json($ua->get("${hs}/_matrix/client/r0/rooms/${room_id}/joined_members?access_token=${access_token}")->decoded_content)->{joined}} ]; -my $group_users = [ map { $_->{user_id} } @{decode_json($ua->get("${hs}/_matrix/client/unstable/groups/${group_id}/users?access_token=${access_token}" )->decoded_content)->{chunk}} ]; +my $group_users = [ + (map { $_->{user_id} } @{decode_json($ua->get("${hs}/_matrix/client/unstable/groups/${group_id}/users?access_token=${access_token}" )->decoded_content)->{chunk}}), + (map { $_->{user_id} } @{decode_json($ua->get("${hs}/_matrix/client/unstable/groups/${group_id}/invited_users?access_token=${access_token}" )->decoded_content)->{chunk}}), +]; my $diff = {}; foreach my $user (@$room_users) { $diff->{$user}++ } @@ -30,10 +33,10 @@ foreach my $user (@$group_users) { $diff->{$user}-- } foreach my $user (keys %$diff) { if ($diff->{$user} == 1) { warn "inviting $user"; - $ua->put("${hs}/_matrix/client/unstable/groups/${group_id}/admin/users/invite/${user}?access_token=${access_token}", Content=>'{}'); + print STDERR $ua->put("${hs}/_matrix/client/unstable/groups/${group_id}/admin/users/invite/${user}?access_token=${access_token}", Content=>'{}')->status_line."\n"; } elsif ($diff->{$user} == -1) { warn "removing $user"; - $ua->put("${hs}/_matrix/client/unstable/groups/${group_id}/admin/users/remove/${user}?access_token=${access_token}", Content=>'{}'); + print STDERR $ua->put("${hs}/_matrix/client/unstable/groups/${group_id}/admin/users/remove/${user}?access_token=${access_token}", Content=>'{}')->status_line."\n"; } } \ No newline at end of file