From 4785d797106bee35e64ea867fd01664e279ab943 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Sun, 10 Sep 2017 10:14:23 +0200 Subject: [PATCH] Support changing join_rules --- scripts/patrix | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/scripts/patrix b/scripts/patrix index e2ecc7c..5f8cf9c 100644 --- a/scripts/patrix +++ b/scripts/patrix @@ -30,6 +30,7 @@ GetOptions( "name=s" => \$opt->{name}, "alias=s" => \$opt->{alias}, "topic=s" => \$opt->{topic}, + "join_rules=s" => \$opt->{join_rules}, "federation!" => \$opt->{federation} ); @@ -291,6 +292,20 @@ sub modify_room { die "Error changing topic of room $opt->{room}\n" unless ($resp->is_success); } + # Changing joining rules + if ($opt->{join_rules}){ + $uri = $opt->{server} . '/_matrix/client/r0/rooms/' . $opt->{room} . '/state/m.room.join_rules?access_token=' . $opt->{access_token}; + $json = { + join_rules => $opt->{join_rules} + }; + $resp = send_request({ + method => 'PUT', + uri => $uri, + content => to_json($json) + }); + die "Error changing joining rules of room $opt->{room}\n" + unless ($resp->is_success); + } # New invitees should be added if ($opt->{invite}){ $uri = $opt->{server} . '/_matrix/client/r0/rooms/' . $opt->{room} . '/invite?access_token=' . $opt->{access_token}; @@ -299,13 +314,13 @@ sub modify_room { user_id => $invite }; $resp = send_request({ - uri => $uri, + uri => $uri, content => to_json($json) }); unless ($resp->is_success){ my $error = from_json($resp->decoded_content); if ($error->{error} eq $invite . ' is already in the room.' && $error->{errcode} eq 'M_FORBIDDEN'){ - debug($invite . 'has already been invited in this room, ignoring'); + debug($invite . ' has already been invited in this room, ignoring'); } else{ die "Error inviting user $invite in room $opt->{room}\n";