1
- package Scot::Email::MSGraph ;
1
+ package Scot::Inbox::Msgraph ;
2
2
3
3
use lib ' ../../../lib' ;
4
4
use strict;
@@ -30,7 +30,7 @@ has permitted_senders => sub ($self) { $self->config->{permitted_senders} };
30
30
31
31
sub get_access_token {
32
32
my ($self ) = @_ ;
33
- my $log = $self -> env -> log ;
33
+ my $log = $self -> log ;
34
34
35
35
my $url = join (' ' ,
36
36
$self -> loginurl,
@@ -59,7 +59,7 @@ sub get_access_token {
59
59
60
60
sub get_mail {
61
61
my ($self , $start , $end ) = @_ ;
62
- my $log = $self -> env -> log ;
62
+ my $log = $self -> log ;
63
63
my $filter = ' &$filter=' ;
64
64
65
65
if ( $self -> bydate ) {
@@ -106,7 +106,6 @@ sub get_mail {
106
106
my $cursor = Scot::Email::MSGraph::Cursor-> new(
107
107
ids => \@mids ,
108
108
msgraph => $self ,
109
- env => $self -> env,
110
109
);
111
110
}
112
111
@@ -121,27 +120,27 @@ sub mark_message_read {
121
120
);
122
121
my $update = {isRead => ' TRUE' };
123
122
$auth -> {' Content-Type' } = " application/json" ;
124
- $self -> env -> log -> debug(" mark_read_url = " ,{filter => \&Dumper, value => $url });
125
- $self -> env -> log -> debug(" mark_read_json = " ,{filter => \&Dumper, value => $auth });
123
+ $self -> log -> debug(" mark_read_url = " ,{filter => \&Dumper, value => $url });
124
+ $self -> log -> debug(" mark_read_json = " ,{filter => \&Dumper, value => $auth });
126
125
my $tx = $self -> ua-> patch($url => $auth => json => $update );
127
126
my $result = $tx -> result;
128
127
129
128
if ($result -> is_error) {
130
- $self -> env -> log -> error(" ERROR updating isRead status!" );
129
+ $self -> log -> error(" ERROR updating isRead status!" );
131
130
my $json = $result -> json;
132
- $self -> env -> log -> error({filter => \&Dumper, value => $json });
131
+ $self -> log -> error({filter => \&Dumper, value => $json });
133
132
return ;
134
133
}
135
134
136
- $self -> env -> log -> debug(" $msgid isRead set to 1" );
135
+ $self -> log -> debug(" $msgid isRead set to 1" );
137
136
return ;
138
137
}
139
138
140
139
sub build_message_id_list {
141
140
my $self = shift ;
142
141
my $messages = shift ;
143
142
my @mids = ();
144
- my $log = $self -> env -> log ;
143
+ my $log = $self -> log ;
145
144
146
145
MSG:
147
146
foreach my $m (@$messages ) {
@@ -167,7 +166,7 @@ sub build_auth_token {
167
166
sub get_message {
168
167
my $self = shift ;
169
168
my $id = shift ;
170
- my $log = $self -> env -> log ;
169
+ my $log = $self -> log ;
171
170
my $url = join (' ' ,
172
171
$self -> graphurl,
173
172
' /' , $self -> useraddress,
@@ -213,13 +212,13 @@ sub get_html_body {
213
212
if ( $body -> {contentType } eq " html" ) {
214
213
return $body -> {content };
215
214
}
216
- $self -> env -> log -> warn (" No HTML body found!" );
215
+ $self -> log -> warn (" No HTML body found!" );
217
216
return ' ' ;
218
217
}
219
218
220
219
sub get_plain_body {
221
220
my ($self , $url , $auth ) = @_ ;
222
- my $log = $self -> env -> log ;
221
+ my $log = $self -> log ;
223
222
$log -> debug(" attempting to get plain body" );
224
223
$auth -> {Prefer } = ' outlook.body-content-type="text"' ;
225
224
my $tx = $self -> ua-> get($url => $auth );
@@ -230,7 +229,7 @@ sub get_plain_body {
230
229
231
230
sub get_attachments {
232
231
my ($self , $id ) = @_ ;
233
- my $log = $self -> env -> log ;
232
+ my $log = $self -> log ;
234
233
my $url = join (' ' ,
235
234
$self -> graphurl,
236
235
' /messages/' ,$id ,' /attachments' );
@@ -270,7 +269,7 @@ sub get_mime {
270
269
$url .= ' /$value' ; # will retrieve the mime version of the email
271
270
$auth = $self -> build_auth_token if (! defined $auth );
272
271
273
- my $log = $self -> env -> log ;
272
+ my $log = $self -> log ;
274
273
$log -> debug(" Getting MIME message with $url " );
275
274
276
275
my $tx = $self -> ua-> get($url => $auth );
@@ -341,7 +340,7 @@ sub from_permitted_sender {
341
340
my $self = shift ;
342
341
my $from = shift ;
343
342
my @oksenders = @{$self -> permitted_senders};
344
- my $log = $self -> env -> log ;
343
+ my $log = $self -> log ;
345
344
346
345
# each permitted sender can be a regex,
347
346
# a '*' match all wildcard, or and explicit
0 commit comments