line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Google::Voice::Feed; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
4
|
1
|
|
|
1
|
|
9
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
561
|
use Google::Voice::SMS::Message; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
44
|
use Mojo::Base -base; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
|
|
776
|
use constant FEED_TYPE => { |
11
|
|
|
|
|
|
|
2 => 'voicemail', |
12
|
|
|
|
|
|
|
10 => 'sms', |
13
|
|
|
|
|
|
|
4 => 'recorded', |
14
|
|
|
|
|
|
|
7 => 'placed', |
15
|
|
|
|
|
|
|
1 => 'received', |
16
|
|
|
|
|
|
|
0 => 'missed', |
17
|
|
|
|
|
|
|
11 => 'trash', |
18
|
|
|
|
|
|
|
10 => 'starred', |
19
|
1
|
|
|
1
|
|
164
|
}; |
|
1
|
|
|
|
|
2
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
__PACKAGE__->attr([qw/ xml id type name meta text rnr_se ua /]); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new { |
24
|
0
|
|
|
0
|
1
|
|
my $self = bless {}, shift; |
25
|
0
|
|
|
|
|
|
my $xml = shift; |
26
|
0
|
|
|
|
|
|
my $meta = shift; |
27
|
0
|
|
|
|
|
|
my $rnr_se = shift; |
28
|
0
|
|
|
|
|
|
my $ua = shift; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
$self->xml($xml); |
31
|
0
|
|
|
|
|
|
$self->id($xml->attrs->{id}); |
32
|
0
|
|
|
|
|
|
$self->name($self->_message_name($xml->at('.gc-message-name-link'))); |
33
|
0
|
|
|
|
|
|
$self->meta($meta->{messages}->{$self->id}); |
34
|
0
|
|
|
|
|
|
$self->type(FEED_TYPE->{$self->meta->{type}}); |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
$self->text("@{[map $_->text, @{$xml->find('.gc-orig-trans > span')}]}"); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
$self->rnr_se($rnr_se); |
39
|
0
|
|
|
|
|
|
$self->ua($ua); |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
return $self; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _message_name { |
45
|
0
|
|
|
0
|
|
|
my $self = shift; |
46
|
0
|
|
|
|
|
|
my $node = shift; |
47
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
return $node->text if $node; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return ''; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub messages { |
54
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Each text message is a span.gc-message-sms-row |
57
|
|
|
|
|
|
|
return |
58
|
0
|
|
|
|
|
|
map Google::Voice::SMS::Message->new($_, $self->meta, $self->rnr_se, |
59
|
|
|
|
|
|
|
$self->ua), |
60
|
0
|
|
|
|
|
|
@{$self->xml->find('.gc-message-sms-row')}; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
0
|
1
|
|
sub latest { return (shift->messages)[-1] } |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub delete { |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
my $json = $self->ua->post( |
70
|
|
|
|
|
|
|
'https://www.google.com/voice/inbox/deleteMessages' => form => { |
71
|
|
|
|
|
|
|
messages => $self->id, |
72
|
|
|
|
|
|
|
trash => 1, |
73
|
|
|
|
|
|
|
_rnr_se => $self->rnr_se |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
)->res->json; |
76
|
|
|
|
|
|
|
|
77
|
0
|
0
|
0
|
|
|
|
$@ = $json->{data}->{code} and return unless $json->{ok}; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
return $json->{ok}; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub download { |
83
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
84
|
0
|
|
|
|
|
|
my ($from, $to) = @_; |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
my $res = $self->ua->get( |
87
|
|
|
|
|
|
|
'https://www.google.com/voice/media/send_voicemail/' . $self->id)->res; |
88
|
|
|
|
|
|
|
|
89
|
0
|
0
|
0
|
|
|
|
$@ = $res->message and return if $res->code != 200; |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
return $res->content->asset; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 NAME |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Google::Voice::Feed |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 DESCRIPTION |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
All feeds (voicemail, text, recorded, placed, received, missed, history |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 id |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Unique id |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 name |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Sender's name |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 meta |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Metadata hashref |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head2 text (voicemail feed only) |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Text transcription of voicemail |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 xml |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Raw xml |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 METHODS |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 messages (sms feed only) |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
List of messages in sms conversation, Google::Voice::SMS::Message objects |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 latest (sms feed only) |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Most recent sms message |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 delete |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Remove conversation |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 download |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Download associated audio (mp3 format) |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |