summaryrefslogtreecommitdiff
path: root/lib/JWebmail/Model/ReadMails/MockMaildir.pm
diff options
context:
space:
mode:
authorJannis M. Hoffmann <jannis@fehcom.de>2023-03-10 13:54:57 +0100
committerJannis M. Hoffmann <jannis@fehcom.de>2023-03-10 13:54:57 +0100
commitfcf5549584b69e62b6c2f0eb919f6799c7904211 (patch)
treee5f0e480af0f39f1c0f457ea0aca8d33f8fb4d0b /lib/JWebmail/Model/ReadMails/MockMaildir.pm
parentdf59f9dec32d7f8f08706fd3eb5b784deaa0abfc (diff)
Proper recursive rendering of mails to html
1. Added raw mode to model 2. Added raw route 3. Moved readmail view parts to RenderMail plugin 4. Renamed displayheaders partial templates
Diffstat (limited to 'lib/JWebmail/Model/ReadMails/MockMaildir.pm')
-rw-r--r--lib/JWebmail/Model/ReadMails/MockMaildir.pm34
1 files changed, 9 insertions, 25 deletions
diff --git a/lib/JWebmail/Model/ReadMails/MockMaildir.pm b/lib/JWebmail/Model/ReadMails/MockMaildir.pm
index 9b1bb29..de5c745 100644
--- a/lib/JWebmail/Model/ReadMails/MockMaildir.pm
+++ b/lib/JWebmail/Model/ReadMails/MockMaildir.pm
@@ -14,12 +14,12 @@ use constant {
has user => sub { $ENV{USER} };
has maildir => 't/';
-has extractor => 'perl';
+has extractor => 'python';
our %EXTRACTORS = (
- perl => 'perl script/qmauth.pl',
- python => 'python script/qmauth.py',
- rust => 'extract/target/debug/jwebmail-extract',
+ perl => 'script/qmauth.pl',
+ python => 'script/qmauth.py',
+ rust => 'bin/jwebmail-extract',
);
@@ -51,33 +51,17 @@ sub verify_user {
}
}
-sub build_and_run {
+sub start_qmauth {
my $self = shift;
my ($auth, $mode, $args) = @_;
my $mail_user = 'maildir';
- my $exec = $EXTRACTORS{$self->extractor} . ' ' . join(' ', map { my $x = s/(['\\])/\\$1/gr; "'$x'" } ($self->maildir, $self->user, $mail_user, $mode, @$args));
+ my @exec = ($EXTRACTORS{$self->extractor}, $self->maildir, $self->user, $mail_user, $mode, @$args);
- my $pid = open(my $reader, '-|', $exec)
- or die 'failed to create subprocess';
+ my $pid = open(my $reader, '-|', @exec)
+ or die "failed to create subprocess: $!";
- my $input = <$reader>;
-
- waitpid($pid, 0);
- my $rc = $? >> 8;
-
- my $resp;
- if ($rc == 3 || $rc == 0) {
- eval { $resp = decode_json $input; };
- if (my $err = $@) { $resp = {error => "decoding error '$err'"}; $rc ||= 1; };
- }
- elsif ($rc) {
- $resp = {error => "qmauth returned code: $rc"};
- }
-
- local $" = ', ';
- die "error @{[%$resp]}" if $rc;
- return $resp;
+ return $pid, $reader;
}