View | Details | Raw Unified | Return to bug 18990
Collapse All | Expand All

(-)a/C4/Letters.pm (-2 / +2 lines)
Lines 1055-1066 sub SendQueuedMessages { Link Here
1055
                    _set_message_status( { message_id => $message->{'message_id'}, status => 'failed' } );
1055
                    _set_message_status( { message_id => $message->{'message_id'}, status => 'failed' } );
1056
                    next MESSAGE;
1056
                    next MESSAGE;
1057
                }
1057
                }
1058
                $message->{to_address} ||= $patron->smsalertnumber;
1058
                unless ( $patron->smsalertnumber ) {
1059
                unless ( $message->{to_address} && $patron->smsalertnumber ) {
1060
                    _set_message_status( { message_id => $message->{'message_id'}, status => 'failed' } );
1059
                    _set_message_status( { message_id => $message->{'message_id'}, status => 'failed' } );
1061
                    warn sprintf( "No smsalertnumber found for patron %s!", $message->{'borrowernumber'} ) if $params->{'verbose'} or $debug;
1060
                    warn sprintf( "No smsalertnumber found for patron %s!", $message->{'borrowernumber'} ) if $params->{'verbose'} or $debug;
1062
                    next MESSAGE;
1061
                    next MESSAGE;
1063
                }
1062
                }
1063
                $message->{to_address}  = $patron->smsalertnumber; #Sometime this is set to email - sms should always use smsalertnumber
1064
                $message->{to_address} .= '@' . $sms_provider->domain();
1064
                $message->{to_address} .= '@' . $sms_provider->domain();
1065
                _update_message_to_address($message->{'message_id'},$message->{to_address});
1065
                _update_message_to_address($message->{'message_id'},$message->{to_address});
1066
                _send_message_by_email( $message, $params->{'username'}, $params->{'password'}, $params->{'method'} );
1066
                _send_message_by_email( $message, $params->{'username'}, $params->{'password'}, $params->{'method'} );
(-)a/t/db_dependent/Letters.t (-3 / +12 lines)
Lines 632-638 subtest 'TranslateNotices' => sub { Link Here
632
632
633
subtest 'SendQueuedMessages' => sub {
633
subtest 'SendQueuedMessages' => sub {
634
634
635
    plan tests => 2;
635
    plan tests => 3;
636
    t::lib::Mocks::mock_preference( 'SMSSendDriver', 'Email' );
636
    t::lib::Mocks::mock_preference( 'SMSSendDriver', 'Email' );
637
    my $patron = Koha::Patrons->find($borrowernumber);
637
    my $patron = Koha::Patrons->find($borrowernumber);
638
    $dbh->do(q|
638
    $dbh->do(q|
Lines 651-657 subtest 'SendQueuedMessages' => sub { Link Here
651
        borrowernumber => $borrowernumber,
651
        borrowernumber => $borrowernumber,
652
        status => 'sent'
652
        status => 'sent'
653
    })->next()->to_address();
653
    })->next()->to_address();
654
    is( $sms_message_address, '5555555555@kidclamp.rocks', 'SendQueuedMessages populates the to address correctly for SMS by email' );
654
    is( $sms_message_address, '5555555555@kidclamp.rocks', 'SendQueuedMessages populates the to address correctly for SMS by email when to_address not set' );
655
    $schema->resultset('MessageQueue')->search({borrowernumber => $borrowernumber,status => 'sent'})->delete(); #clear borrower queue
656
    $my_message->{to_address} = 'fixme@kidclamp.iswrong';
657
    $message_id = C4::Letters::EnqueueLetter($my_message);
658
    C4::Letters::SendQueuedMessages();
659
    $sms_message_address = $schema->resultset('MessageQueue')->search({
660
        borrowernumber => $borrowernumber,
661
        status => 'sent'
662
    })->next()->to_address();
663
    is( $sms_message_address, '5555555555@kidclamp.rocks', 'SendQueuedMessages populates the to address correctly for SMS by email when to_address is set incorrectly' );
664
655
};
665
};
656
666
657
subtest 'get_item_content' => sub {
667
subtest 'get_item_content' => sub {
658
- 

Return to bug 18990