summary refs log tree commit diff
path: root/scripts/sync_room_to_group.pl
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/sync_room_to_group.pl')
-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