diff options
author | Jannis M. Hoffmann <jannis@fehcom.de> | 2023-02-26 21:36:27 +0100 |
---|---|---|
committer | Jannis M. Hoffmann <jannis@fehcom.de> | 2023-02-26 21:36:27 +0100 |
commit | 2abf462ca10c4ac8c4f815e608cad31851e966e3 (patch) | |
tree | ed18c4a4039a5972edc0b81ed79c9d57480f8e70 /lib/JWebmail.pm | |
parent | d0ffe11bd365b68d4da252b39d06d99f75d8cacb (diff) |
Specified the interface for qmauth
Changes to configuration
Added qmauth version written in Python
Slight changes to pagination
Diffstat (limited to 'lib/JWebmail.pm')
-rw-r--r-- | lib/JWebmail.pm | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/lib/JWebmail.pm b/lib/JWebmail.pm index 1c66001..3abc78d 100644 --- a/lib/JWebmail.pm +++ b/lib/JWebmail.pm @@ -1,4 +1,4 @@ -package JWebmail v1.2.0; +package JWebmail v1.2.1; use Mojo::Base Mojolicious; @@ -10,27 +10,18 @@ use JWebmail::Model::ReadMails::QMailAuthuser; use JWebmail::Model::WriteMails; -sub nest { -} sub validateConf { my $self = shift; my $conf = $self->config; - my $v = $self->validator->validation->input($conf); - $v->optional('secret', 'not_empty'); + exists $conf->{session}{secure} or die; + grep(sub { $_ eq $conf->{session}{secure} }, qw(none cram s3d)) > 0 or die; - $v->optional('i18n'); - $v->required('session')->required('secure')->in(qw(none cram s3d)); - $v->required('defaults')->required('scriptadmin')->like(qr/@/); - my $dev = $v->optional('development'); - $dev->optional('read_mock', 'not_empty'); - $dev->optional('block_writes')->in(0, 1); + exists $conf->{defaults}{scriptadmin} or die; + $conf->{defaults}{scriptadmin} =~ /@/ or die; - for ($v->failed->@*) { - say "reasons for $_: " , $v->error($_)->@*; - } - $v->is_valid; + return 1; } @@ -39,15 +30,19 @@ sub startup { $self->moniker('jwebmail'); - $self->log->path($self->home->child('log', $self->mode . '.log')); - # load plugins push @{$self->plugins->namespaces}, 'JWebmail::Plugin'; $self->plugin('TOMLConfig'); - #die unless $self->validateConf; + $self->validateConf; - $self->plugin('ServerSideSessionData'); + if (my $logpath = $self->config('logpath')) { + $self->log->path($logpath . '/' . $self->mode . '.log'); + } + + if (fc $self->config->{session}{secure} eq fc 's3d') { + $self->plugin('ServerSideSessionData'); + } $self->plugin('Helper'); my $i18n_route = $self->plugin('I18N2', $self->config('i18n')); @@ -57,21 +52,22 @@ sub startup { # initialize models my $read_mails = do { if ($self->mode eq 'development') { - my $cls = $self->config->{development}{read_mock}; + my $cls = $self->config->{model}{read}{devel}{driver}; eval { load $cls; 1 } || die "Issue for module $cls with: $@"; - $cls->new(); + $cls->new(($self->config->{model}{read}{devel} // {})->%*) } else { JWebmail::Model::ReadMails::QMailAuthuser->new( - logfile => $self->home->child('log', 'extract.log'), - ); + ($self->config->{model}{read}{prod} // {})->%* + ) } }; die "given class @{[ ref $read_mails ]} does not ReadMails" unless $read_mails->DOES('JWebmail::Model::ReadMails::Role'); $self->helper(users => sub { $read_mails }); $self->helper(send_mail => sub { my ($c, $mail) = @_; JWebmail::Model::WriteMails::sendmail($mail) }); - $JWebmail::Model::WriteMails::Block_Writes = 1 if $self->mode eq 'development'; + $JWebmail::Model::WriteMails::Block_Writes = 1 + if $self->mode eq 'development' && $self->config->{model}{write}{devel}{block_writes}; $self->defaults(version => __PACKAGE__->VERSION); @@ -98,7 +94,7 @@ sub route { $a->get('/home/*folder')->to('Webmail#displayheaders', folder => '')->name('displayheaders'); $a->get('/read/#id' => 'read')->to('Webmail#readmail'); $a->get('/write')->to('Webmail#writemail'); - $a->post('/write' => 'send')-> to('Webmail#sendmail'); + $a->post('/write' => 'send')->to('Webmail#sendmail'); $a->post('/move')->to('Webmail#move'); } |