summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorMatthew Hodgson <matthew@matrix.org>2017-11-19 00:48:38 +0000
committerMatthew Hodgson <matthew@matrix.org>2017-11-19 00:48:47 +0000
commit2145ee19769b8160d8ab8b02d29bbe42563a627f (patch)
treebe3dd868f0bad5260c01be8aa3d64405a07b9e8d /scripts
parentMerge pull request #2688 from matrix-org/rav/unlock_more_upsert (diff)
downloadsynapse-2145ee19769b8160d8ab8b02d29bbe42563a627f.tar.xz
don't double-invite in sync_room_to_group.pl
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/sync_room_to_group.pl9
1 files 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