mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-25 19:39:21 -05:00
don't double-invite in sync_room_to_group.pl
This commit is contained in:
parent
59a7275258
commit
2145ee1976
@ -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 $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 = {};
|
my $diff = {};
|
||||||
foreach my $user (@$room_users) { $diff->{$user}++ }
|
foreach my $user (@$room_users) { $diff->{$user}++ }
|
||||||
@ -30,10 +33,10 @@ foreach my $user (@$group_users) { $diff->{$user}-- }
|
|||||||
foreach my $user (keys %$diff) {
|
foreach my $user (keys %$diff) {
|
||||||
if ($diff->{$user} == 1) {
|
if ($diff->{$user} == 1) {
|
||||||
warn "inviting $user";
|
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) {
|
elsif ($diff->{$user} == -1) {
|
||||||
warn "removing $user";
|
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";
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user