Skip to content

Commit

Permalink
4.3 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
toddbruner committed Feb 13, 2025
1 parent 488044e commit a310f6b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 24 deletions.
4 changes: 2 additions & 2 deletions lib/Scot/Inbox/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ sub build_config () {
$mboxconf = {
loginurl => $ENV{S4INBOX_GRAPH_LOGIN_URL},
graphurl => $ENV{S4INBOX_GRAPH_GRAPH_URL},
scot => $ENV{S4INBOX_GRAPH_SCOPE},
tenet_id => $ENV{S4INBOX_GRAPH_TENENT_ID},
scope => $ENV{S4INBOX_GRAPH_SCOPE},
tenet_id => $ENV{S4INBOX_GRAPH_TENET_ID},
client_id => $ENV{S4INBOX_GRAPH_CLIENT_ID},
client_secret => $ENV{S4INBOX_GRAPH_CLIENT_SECRET},
useraddress => $ENV{S4INBOX_GRAPH_USERADDRESS},
Expand Down
4 changes: 4 additions & 0 deletions lib/Scot/Inbox/Imap.pm
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,10 @@ sub inline_images ($self, $tree, $imgdb) {
}
}

sub delete_message ($self, @msgids) {
$self->client->delete_message(\@msgids);
}


1;

31 changes: 15 additions & 16 deletions lib/Scot/Inbox/Msgraph.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Scot::Email::MSGraph;
package Scot::Inbox::Msgraph;

use lib '../../../lib';
use strict;
Expand Down Expand Up @@ -30,7 +30,7 @@ has permitted_senders => sub ($self) { $self->config->{permitted_senders} };

sub get_access_token {
my ($self) = @_;
my $log = $self->env->log;
my $log = $self->log;

my $url = join('',
$self->loginurl,
Expand Down Expand Up @@ -59,7 +59,7 @@ sub get_access_token {

sub get_mail {
my ($self, $start, $end) = @_;
my $log = $self->env->log;
my $log = $self->log;
my $filter = '&$filter=';

if ( $self->bydate ) {
Expand Down Expand Up @@ -106,7 +106,6 @@ sub get_mail {
my $cursor = Scot::Email::MSGraph::Cursor->new(
ids => \@mids,
msgraph => $self,
env => $self->env,
);
}

Expand All @@ -121,27 +120,27 @@ sub mark_message_read {
);
my $update = {isRead => 'TRUE' };
$auth->{'Content-Type'} = "application/json";
$self->env->log->debug("mark_read_url = ",{filter =>\&Dumper, value => $url});
$self->env->log->debug("mark_read_json = ",{filter =>\&Dumper, value => $auth});
$self->log->debug("mark_read_url = ",{filter =>\&Dumper, value => $url});
$self->log->debug("mark_read_json = ",{filter =>\&Dumper, value => $auth});
my $tx = $self->ua->patch($url => $auth => json => $update);
my $result = $tx->result;

if ($result->is_error) {
$self->env->log->error("ERROR updating isRead status!");
$self->log->error("ERROR updating isRead status!");
my $json = $result->json;
$self->env->log->error({filter => \&Dumper, value => $json});
$self->log->error({filter => \&Dumper, value => $json});
return;
}

$self->env->log->debug("$msgid isRead set to 1");
$self->log->debug("$msgid isRead set to 1");
return;
}

sub build_message_id_list {
my $self = shift;
my $messages = shift;
my @mids = ();
my $log = $self->env->log;
my $log = $self->log;

MSG:
foreach my $m (@$messages) {
Expand All @@ -167,7 +166,7 @@ sub build_auth_token {
sub get_message {
my $self = shift;
my $id = shift;
my $log = $self->env->log;
my $log = $self->log;
my $url = join('',
$self->graphurl,
'/', $self->useraddress,
Expand Down Expand Up @@ -213,13 +212,13 @@ sub get_html_body {
if ( $body->{contentType} eq "html" ) {
return $body->{content};
}
$self->env->log->warn("No HTML body found!");
$self->log->warn("No HTML body found!");
return '';
}

sub get_plain_body {
my ($self, $url, $auth) = @_;
my $log = $self->env->log;
my $log = $self->log;
$log->debug("attempting to get plain body");
$auth->{Prefer} = 'outlook.body-content-type="text"';
my $tx = $self->ua->get($url => $auth);
Expand All @@ -230,7 +229,7 @@ sub get_plain_body {

sub get_attachments {
my ($self, $id) = @_;
my $log = $self->env->log;
my $log = $self->log;
my $url = join('',
$self->graphurl,
'/messages/',$id,'/attachments');
Expand Down Expand Up @@ -270,7 +269,7 @@ sub get_mime {
$url .= '/$value'; # will retrieve the mime version of the email
$auth = $self->build_auth_token if (! defined $auth);

my $log = $self->env->log;
my $log = $self->log;
$log->debug("Getting MIME message with $url");

my $tx = $self->ua->get($url => $auth);
Expand Down Expand Up @@ -341,7 +340,7 @@ sub from_permitted_sender {
my $self = shift;
my $from = shift;
my @oksenders = @{$self->permitted_senders};
my $log = $self->env->log;
my $log = $self->log;

# each permitted sender can be a regex,
# a '*' match all wildcard, or and explicit
Expand Down
6 changes: 1 addition & 5 deletions lib/Scot/Inbox/Msgraph/Cursor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@ has ids => (
}
);

has env => (
is => 'ro', isa => 'Scot::Env', required => 1
);

has msgraph => (
is => 'rw', isa => 'Scot::Email::MSGraph', required => 1
is => 'rw', isa => 'Scot::Inbox::Msgraph', required => 1
);

sub count {
Expand Down
2 changes: 1 addition & 1 deletion lib/Scot/Inbox/Processor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ sub delete ($self) {
$log->logdie("Failed to create $class, unable to process inbox");
}

my $cursor = $client->get_mail;
my $cursor = $client->get_before_cursor;
my $count = $cursor->count;
my $index = 0;
my $target = $config->{scot_queue};
Expand Down

0 comments on commit a310f6b

Please sign in to comment.