MatrixTool/Command/client/list_rooms.pm

filter: Statementstmt 74.0% 20 / 27 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 6 / 8 Podpod 0.0% 0 / 1 totaltotal 72.2% 26 / 36 CC 2 SCAR 8.0
CC
2
Cov
74%
__ANON__
6.0
run
2.0
BEGIN
1.0
CRAP 2.2
« MatrixTool/Command/client/login.pm ↑ Summary
1 # You may distribute under the terms of either the GNU General Public License
2 # or the Artistic License (the same terms as Perl itself)
3 #
4 # (C) Paul Evans, 2016 -- leonerd@leonerd.org.uk
5  
6 package App::MatrixTool::Command::client::list_rooms;
7  
8 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use base qw( App::MatrixTool::Command::client );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 our $VERSION = '0.08';
13  
14 1 ▶use constant DESCRIPTION => "List the rooms the user is in";
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use constant ARGUMENTS => ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use constant OPTIONS => ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 =head1 NAME
19  
20 matrixtool client list-rooms - List the room IDs I am a member of
21  
22 =head1 SYNOPSIS
23  
24 This command prints a list of room IDs that the calling user has C<join>
25 membership of.
26  
27 =cut
28  
29 sub run
30 0 ▶{
Subroutine run: not called CC=1 SCAR=6.9
Pod undocumented
31 0 my $self = shift;
32  
33 # the Matrix spec doesn't have a nice way to ask what rooms I'm a member
34 # of. About the best we can do is a /sync request with a filter that asks
35 # for just the m.room.create event in each room while throwing away all the
36 # timeline, account_data and presence.
37 # See also
38 # https://github.com/matrix-org/matrix-doc/issues/734
39  
40 $self->do_json( GET => "/_matrix/client/r0/sync",
41 params => {
42 filter =>
43 '{"room":{' .
44 '"timeline":{"limit":0},' .
45 '"state":{"types":["m.room.create"]},' .
46 '"ephemeral":{"types":[]}' .
47 '},' .
48 '"presence":{"types":[]},' .
49 '"account_data":{"types":[]}}',
50 }
51 0 ▶ )->then( sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
52 0 my ( $body ) = @_;
53  
54 0 my $rooms = $body->{rooms};
55  
56 0 print "$_\n" for keys %{ $rooms->{join} };
57 # TODO: think about invite and leave
58  
59 0 Future->done;
60 0 });
61 }
62  
63 =head1 AUTHOR
64  
65 Paul Evans <leonerd@leonerd.org.uk>
66  
67 =cut
68  
69 1 0x55AA;
« MatrixTool/Command/client/login.pm ↑ Summary