Commit 70941cde authored by Mark Tompsett's avatar Mark Tompsett Committed by joubu

Bug 18570: Send Password Reset Emails immediately

Run through the password reset process, and your server
should send the message immediate, not waiting for the
cronjob.
Signed-off-by: Josef Moravec's avatarJosef Moravec <josef.moravec@gmail.com>
Signed-off-by: default avatarJulian Maurice <julian.maurice@biblibre.com>
Signed-off-by: joubu's avatarJonathan Druart <jonathan.druart@bugs.koha-community.org>
parent f0772f0c
......@@ -1038,7 +1038,12 @@ Returns number of messages sent.
sub SendQueuedMessages {
my $params = shift;
my $unsent_messages = _get_unsent_messages( { limit => $params->{limit} } );
my $which_unsent_messages = {
'limit' => $params->{'limit'} // 0,
'borrowernumber' => $params->{'borrowernumber'} // q{},
'letter_code' => $params->{'letter_code'} // q{},
};
my $unsent_messages = _get_unsent_messages( $which_unsent_messages );
MESSAGE: foreach my $message ( @$unsent_messages ) {
# warn Data::Dumper->Dump( [ $message ], [ 'message' ] );
warn sprintf( 'sending %s message to patron: %s',
......@@ -1282,13 +1287,17 @@ sub _get_unsent_messages {
my @query_params = ('pending');
if ( ref $params ) {
if ( $params->{'message_transport_type'} ) {
$statement .= ' AND message_transport_type = ? ';
$statement .= ' AND mq.message_transport_type = ? ';
push @query_params, $params->{'message_transport_type'};
}
if ( $params->{'borrowernumber'} ) {
$statement .= ' AND borrowernumber = ? ';
$statement .= ' AND mq.borrowernumber = ? ';
push @query_params, $params->{'borrowernumber'};
}
if ( $params->{'letter_code'} ) {
$statement .= ' AND mq.letter_code = ? ';
push @query_params, $params->{'letter_code'};
}
if ( $params->{'limit'} ) {
$statement .= ' limit ? ';
push @query_params, $params->{'limit'};
......
......@@ -161,8 +161,11 @@ sub SendPasswordRecoveryEmail {
message_transport_type => 'email',
}
);
return 1;
my $num_letters_attempted = C4::Letters::SendQueuedMessages( {
borrowernumber => $borrower->borrowernumber,
letter_code => 'PASSWORD_RESET'
} );
return ($num_letters_attempted > 0);
}
=head2 CompletePasswordRecovery
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment