This file is indexed.

/usr/share/perl5/App/Alice/MessageStore/Redis.pm is in alice 0.19-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package App::Alice::MessageStore::Redis;

use Any::Moose;
use AnyEvent::Redis;
use JSON;

my $redis = AnyEvent::Redis->new;

has id => (
  is => 'ro',
  required => 1
);

has buffersize => (
  is => 'ro',
  default => 100
);

has lrange_size => (
  is => 'ro',
  default => 15
);

sub add {
  my ($self, $message) = @_;
  return unless $message;
  $redis->rpush($self->id, encode_json $message);
  $redis->llen($self->id, sub {
    $redis->lpop($self->id) if $_[0] > $self->buffersize;
  });
}

sub clear {
  my $self = shift;
  $redis->del($self->id);
}

sub with_messages {
  my ($self, $cb, $start, $complete_cb) = @_;

  $start ||= 0;
  my $end = $start + $self->lrange_size - 1;
  $end = $self->buffersize if $end > $self->buffersize;

  $redis->lrange(
    $self->id, $start, $end, sub {
      my $msgs = ref $_[0] eq 'ARRAY' ? $_[0] : [];
      $cb->(
        grep {$_}
        map  {my $msg = eval {decode_json $_ }; $@ ? undef : $msg}
        @$msgs
      );
      if ($end == $self->buffersize or @$msgs != $self->lrange_size) {
        $complete_cb->() if $complete_cb;
      } else {
        $self->with_messages($cb, $end + 1, $complete_cb);
      }
    }
  );
}

__PACKAGE__->meta->make_immutable;
1;