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

(-)a/C4/Letters.pm (-1 / +21 lines)
Lines 1019-1024 $content Link Here
1019
EOS
1019
EOS
1020
}
1020
}
1021
1021
1022
sub _is_duplicate {
1023
    my ( $message ) = @_;
1024
    my $dbh = C4::Context->dbh;
1025
    my $count = $dbh->selectrow_array(q|
1026
        SELECT COUNT(*)
1027
        FROM message_queue
1028
        WHERE message_transport_type = ?
1029
        AND borrowernumber = ?
1030
        AND letter_code = ?
1031
        AND CAST(time_queued AS date) = CAST(? AS date)
1032
        AND status="sent"
1033
    |, {}, $message->{message_transport_type}, $message->{borrowernumber}, $message->{letter_code}, $message->{time_queued} );
1034
    return $count;
1035
}
1036
1022
sub _send_message_by_sms {
1037
sub _send_message_by_sms {
1023
    my $message = shift or return;
1038
    my $message = shift or return;
1024
    my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} );
1039
    my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} );
Lines 1029-1034 sub _send_message_by_sms { Link Here
1029
        return;
1044
        return;
1030
    }
1045
    }
1031
1046
1047
    if ( _is_duplicate( $message ) ) {
1048
        _set_message_status( { message_id => $message->{'message_id'},
1049
                               status     => 'failed' } );
1050
        return;
1051
    }
1052
1032
    my $success = C4::SMS->send_sms( { destination => $member->{'smsalertnumber'},
1053
    my $success = C4::SMS->send_sms( { destination => $member->{'smsalertnumber'},
1033
                                       message     => $message->{'content'},
1054
                                       message     => $message->{'content'},
1034
                                     } );
1055
                                     } );
1035
- 

Return to bug 11209