Append defaulCondition option (#2012)
This commit is contained in:
parent
ea3337574c
commit
e20555623e
|
@ -159,7 +159,8 @@ sub defaultValues {
|
|||
'multiValuesSeparator' => '; ',
|
||||
'mySessionAuthorizedRWKeys' =>
|
||||
[ '_appsListOrder', '_oidcConnectedRP', '_oidcConsents' ],
|
||||
'notificationServerPOST' => 1,
|
||||
'notificationDefaultCond' => '',
|
||||
'notificationServerPOST' => 1,
|
||||
'notificationServerSentAttributes' =>
|
||||
'uid reference date title subtitle text check',
|
||||
'notificationStorage' => 'File',
|
||||
|
|
|
@ -4,11 +4,12 @@ use strict;
|
|||
use Mouse;
|
||||
use JSON qw(from_json to_json);
|
||||
|
||||
our $VERSION = '2.0.6';
|
||||
our $VERSION = '2.0.7';
|
||||
|
||||
sub newNotification {
|
||||
my ( $self, $jsonString ) = @_;
|
||||
my ( $self, $jsonString, $defaultCond ) = @_;
|
||||
my $json;
|
||||
$defaultCond ||= '';
|
||||
eval { $json = from_json( $jsonString, { allow_nonref => 1 } ) };
|
||||
if ( my $err = $@ ) {
|
||||
eval { $self->logger->error("Unable to decode JSON file: $err") };
|
||||
|
@ -35,7 +36,8 @@ sub newNotification {
|
|||
}
|
||||
push @data, $tmp;
|
||||
}
|
||||
push @data, ( $notif->{condition} // '' );
|
||||
$notif->{condition} //= $defaultCond;
|
||||
push @data, ( $notif->{condition} );
|
||||
my $body = to_json($notif);
|
||||
push @notifs, [ @data, $body ];
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ use strict;
|
|||
use Mouse;
|
||||
use XML::LibXML;
|
||||
|
||||
our $VERSION = '2.0.6';
|
||||
our $VERSION = '2.0.7';
|
||||
|
||||
# XML parser
|
||||
has parser => (
|
||||
|
@ -18,7 +18,8 @@ has parser => (
|
|||
# @param $xml XML string containing notification
|
||||
# @return number of notifications done
|
||||
sub newNotification {
|
||||
my ( $self, $xml ) = @_;
|
||||
my ( $self, $xml, $defaultCond ) = @_;
|
||||
$defaultCond ||= '';
|
||||
eval { $xml = $self->parser->parse_string($xml) };
|
||||
if ( my $err = $@ ) {
|
||||
eval { $self->logger->error("Unable to read XML file : $err") };
|
||||
|
@ -53,7 +54,9 @@ sub newNotification {
|
|||
if ( $tmp = $notif->getAttribute($_) ) {
|
||||
push @data, $tmp;
|
||||
}
|
||||
else { push @data, ""; }
|
||||
else {
|
||||
push @data, $defaultCond;
|
||||
}
|
||||
}
|
||||
|
||||
my $result = XML::LibXML::Document->new( $version, $encoding );
|
||||
|
|
|
@ -1796,6 +1796,10 @@ qr/^(?:\*\.)?(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][
|
|||
'default' => 0,
|
||||
'type' => 'bool'
|
||||
},
|
||||
'notificationDefaultCond' => {
|
||||
'default' => '',
|
||||
'type' => 'text'
|
||||
},
|
||||
'notificationServer' => {
|
||||
'default' => 0,
|
||||
'type' => 'bool'
|
||||
|
|
|
@ -450,9 +450,10 @@ sub attributes {
|
|||
flags => 'p',
|
||||
},
|
||||
checkUserSearchAttributes => {
|
||||
type => 'text',
|
||||
documentation => 'Attributes used for retrieving sessions in user DataBase',
|
||||
flags => 'p',
|
||||
type => 'text',
|
||||
documentation =>
|
||||
'Attributes used for retrieving sessions in user DataBase',
|
||||
flags => 'p',
|
||||
},
|
||||
checkUserDisplayPersistentInfo => {
|
||||
default => 0,
|
||||
|
@ -1093,6 +1094,11 @@ sub attributes {
|
|||
type => 'bool',
|
||||
documentation => 'Notification server activation',
|
||||
},
|
||||
notificationDefaultCond => {
|
||||
type => 'text',
|
||||
default => '',
|
||||
documentation => 'Notification default condition',
|
||||
},
|
||||
notificationServerGET => {
|
||||
default => 0,
|
||||
type => 'bool',
|
||||
|
@ -1978,15 +1984,15 @@ sub attributes {
|
|||
vhostType => {
|
||||
type => 'select',
|
||||
select => [
|
||||
{ k => 'AuthBasic', v => 'AuthBasic' },
|
||||
{ k => 'CDA', v => 'CDA' },
|
||||
{ k => 'DevOps', v => 'DevOps' },
|
||||
{ k => 'DevOpsST', v => 'DevOpsST' },
|
||||
{ k => 'Main', v => 'Main' },
|
||||
{ k => 'OAuth2', v => 'OAuth2' },
|
||||
{ k => 'SecureToken', v => 'SecureToken' },
|
||||
{ k => 'ServiceToken', v => 'ServiceToken' },
|
||||
{ k => 'ZimbraPreAuth',v => 'ZimbraPreAuth' },
|
||||
{ k => 'AuthBasic', v => 'AuthBasic' },
|
||||
{ k => 'CDA', v => 'CDA' },
|
||||
{ k => 'DevOps', v => 'DevOps' },
|
||||
{ k => 'DevOpsST', v => 'DevOpsST' },
|
||||
{ k => 'Main', v => 'Main' },
|
||||
{ k => 'OAuth2', v => 'OAuth2' },
|
||||
{ k => 'SecureToken', v => 'SecureToken' },
|
||||
{ k => 'ServiceToken', v => 'ServiceToken' },
|
||||
{ k => 'ZimbraPreAuth', v => 'ZimbraPreAuth' },
|
||||
],
|
||||
default => 'Main',
|
||||
documentation => 'Handler type',
|
||||
|
|
|
@ -615,6 +615,7 @@ sub tree {
|
|||
help => 'notifications.html#server',
|
||||
nodes => [
|
||||
'notificationServer',
|
||||
'notificationDefaultCond',
|
||||
'notificationServerSentAttributes',
|
||||
{
|
||||
title =>
|
||||
|
|
|
@ -258,8 +258,10 @@ sub notificationServer {
|
|||
my ( $res, $err );
|
||||
if ( $req->method =~ /^POST$/i ) {
|
||||
$self->p->logger->debug("POST request");
|
||||
( $res, $err ) =
|
||||
eval { $self->notifObject->newNotification( $req->content, 1 ) };
|
||||
( $res, $err ) = eval {
|
||||
$self->notifObject->newNotification( $req->content,
|
||||
$self->conf->{notificationDefaultCond} );
|
||||
};
|
||||
return $self->p->sendError( $req, $@, 500 ) if ($@);
|
||||
}
|
||||
elsif ( $req->method =~ /^GET$/i ) {
|
||||
|
|
|
@ -293,7 +293,8 @@ sub notificationServer {
|
|||
|
||||
sub newNotification {
|
||||
my ( $self, $req, $xml ) = @_;
|
||||
return $self->notifObject->newNotification($xml);
|
||||
return $self->notifObject->newNotification( $xml,
|
||||
$self->conf->{notificationDefaultCond} );
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
Loading…
Reference in New Issue
Block a user