mirror of https://github.com/watcha-fr/synapse
Move scripts directory inside synapse, exposing as setuptools entry_points (#12118)
* Two scripts are basically entry_points already * Move and rename scripts/* to synapse/_scripts/*.py * Delete sync_room_to_group.pl * Expose entry points in setup.py * Update linter script and config * Fixup scripts & docs mentioning scripts that moved Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>code_spécifique_watcha
parent
6adb89ff00
commit
f3f0ab10fe
@ -0,0 +1 @@ |
|||||||
|
Move scripts to Synapse package and expose as setuptools entry points. |
@ -1,19 +0,0 @@ |
|||||||
#!/usr/bin/env python |
|
||||||
# Copyright 2015, 2016 OpenMarket Ltd |
|
||||||
# |
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||||
# you may not use this file except in compliance with the License. |
|
||||||
# You may obtain a copy of the License at |
|
||||||
# |
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0 |
|
||||||
# |
|
||||||
# Unless required by applicable law or agreed to in writing, software |
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
# See the License for the specific language governing permissions and |
|
||||||
# limitations under the License. |
|
||||||
|
|
||||||
from synapse._scripts.register_new_matrix_user import main |
|
||||||
|
|
||||||
if __name__ == "__main__": |
|
||||||
main() |
|
@ -1,19 +0,0 @@ |
|||||||
#!/usr/bin/env python |
|
||||||
# Copyright 2021 The Matrix.org Foundation C.I.C. |
|
||||||
# |
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||||
# you may not use this file except in compliance with the License. |
|
||||||
# You may obtain a copy of the License at |
|
||||||
# |
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0 |
|
||||||
# |
|
||||||
# Unless required by applicable law or agreed to in writing, software |
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
# See the License for the specific language governing permissions and |
|
||||||
# limitations under the License. |
|
||||||
|
|
||||||
from synapse._scripts.review_recent_signups import main |
|
||||||
|
|
||||||
if __name__ == "__main__": |
|
||||||
main() |
|
@ -1,45 +0,0 @@ |
|||||||
#!/usr/bin/env perl |
|
||||||
|
|
||||||
use strict; |
|
||||||
use warnings; |
|
||||||
|
|
||||||
use JSON::XS; |
|
||||||
use LWP::UserAgent; |
|
||||||
use URI::Escape; |
|
||||||
|
|
||||||
if (@ARGV < 4) { |
|
||||||
die "usage: $0 <homeserver url> <access_token> <room_id|room_alias> <group_id>\n"; |
|
||||||
} |
|
||||||
|
|
||||||
my ($hs, $access_token, $room_id, $group_id) = @ARGV; |
|
||||||
my $ua = LWP::UserAgent->new(); |
|
||||||
$ua->timeout(10); |
|
||||||
|
|
||||||
if ($room_id =~ /^#/) { |
|
||||||
$room_id = uri_escape($room_id); |
|
||||||
$room_id = decode_json($ua->get("${hs}/_matrix/client/r0/directory/room/${room_id}?access_token=${access_token}")->decoded_content)->{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}}), |
|
||||||
(map { $_->{user_id} } @{decode_json($ua->get("${hs}/_matrix/client/unstable/groups/${group_id}/invited_users?access_token=${access_token}" )->decoded_content)->{chunk}}), |
|
||||||
]; |
|
||||||
|
|
||||||
die "refusing to sync from empty room" unless (@$room_users); |
|
||||||
die "refusing to sync to empty group" unless (@$group_users); |
|
||||||
|
|
||||||
my $diff = {}; |
|
||||||
foreach my $user (@$room_users) { $diff->{$user}++ } |
|
||||||
foreach my $user (@$group_users) { $diff->{$user}-- } |
|
||||||
|
|
||||||
foreach my $user (keys %$diff) { |
|
||||||
if ($diff->{$user} == 1) { |
|
||||||
warn "inviting $user"; |
|
||||||
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"; |
|
||||||
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