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

(-)a/C4/Letters.pm (-1 / +7 lines)
Lines 1030-1036 ENDSQL Link Here
1030
        letter_code => $letter_code,
1030
        letter_code => $letter_code,
1031
        borrowernumber => $who_letter_is_for,
1031
        borrowernumber => $who_letter_is_for,
1032
        limit => 50,
1032
        limit => 50,
1033
        verbose => 1
1033
        verbose => 1,
1034
        type => 'sms',
1034
    });
1035
    });
1035
1036
1036
Sends all of the 'pending' items in the message queue, unless
1037
Sends all of the 'pending' items in the message queue, unless
Lines 1054-1059 sub SendQueuedMessages { Link Here
1054
        'limit'          => $params->{'limit'} // 0,
1055
        'limit'          => $params->{'limit'} // 0,
1055
        'borrowernumber' => $params->{'borrowernumber'} // q{},
1056
        'borrowernumber' => $params->{'borrowernumber'} // q{},
1056
        'letter_code'    => $params->{'letter_code'} // q{},
1057
        'letter_code'    => $params->{'letter_code'} // q{},
1058
        'type'           => $params->{'type'} // q{},
1057
    };
1059
    };
1058
    my $unsent_messages = _get_unsent_messages( $which_unsent_messages );
1060
    my $unsent_messages = _get_unsent_messages( $which_unsent_messages );
1059
    MESSAGE: foreach my $message ( @$unsent_messages ) {
1061
    MESSAGE: foreach my $message ( @$unsent_messages ) {
Lines 1324-1329 sub _get_unsent_messages { Link Here
1324
            $statement .= ' AND mq.letter_code = ? ';
1326
            $statement .= ' AND mq.letter_code = ? ';
1325
            push @query_params, $params->{'letter_code'};
1327
            push @query_params, $params->{'letter_code'};
1326
        }
1328
        }
1329
        if ( $params->{'type'} ) {
1330
            $statement .= ' AND message_transport_type = ? ';
1331
            push @query_params, $params->{'type'};
1332
        }
1327
        if ( $params->{'limit'} ) {
1333
        if ( $params->{'limit'} ) {
1328
            $statement .= ' limit ? ';
1334
            $statement .= ' limit ? ';
1329
            push @query_params, $params->{'limit'};
1335
            push @query_params, $params->{'limit'};
(-)a/misc/cronjobs/process_message_queue.pl (-1 / +4 lines)
Lines 35-40 my $limit = undef; Link Here
35
my $method = 'LOGIN';
35
my $method = 'LOGIN';
36
my $help = 0;
36
my $help = 0;
37
my $verbose = 0;
37
my $verbose = 0;
38
my $type = q{};
38
39
39
GetOptions(
40
GetOptions(
40
    'u|username:s'      => \$username,
41
    'u|username:s'      => \$username,
Lines 43-48 GetOptions( Link Here
43
    'm|method:s'        => \$method,
44
    'm|method:s'        => \$method,
44
    'h|help|?'          => \$help,
45
    'h|help|?'          => \$help,
45
    'v|verbose'         => \$verbose,
46
    'v|verbose'         => \$verbose,
47
    't|type'            => \$type,
46
);
48
);
47
my $usage = << 'ENDUSAGE';
49
my $usage = << 'ENDUSAGE';
48
50
Lines 55-65 advance_notices.pl script. Link Here
55
This script has the following parameters :
57
This script has the following parameters :
56
    -u --username: username of mail account
58
    -u --username: username of mail account
57
    -p --password: password of mail account
59
    -p --password: password of mail account
60
    -t --type: If supplied, only processes this type of message ( email, sms )
58
    -l --limit: The maximum number of messages to process for this run
61
    -l --limit: The maximum number of messages to process for this run
59
    -m --method: authentication method required by SMTP server (See perldoc Sendmail.pm for supported authentication types.)
62
    -m --method: authentication method required by SMTP server (See perldoc Sendmail.pm for supported authentication types.)
60
    -h --help: this message
63
    -h --help: this message
61
    -v --verbose: provides verbose output to STDOUT
64
    -v --verbose: provides verbose output to STDOUT
62
63
ENDUSAGE
65
ENDUSAGE
64
66
65
die $usage if $help;
67
die $usage if $help;
Lines 73-78 C4::Letters::SendQueuedMessages( Link Here
73
        password => $password,
75
        password => $password,
74
        method   => $method,
76
        method   => $method,
75
        limit    => $limit,
77
        limit    => $limit,
78
        type     => $type,
76
    }
79
    }
77
);
80
);
78
81
(-)a/t/db_dependent/Letters.t (-4 / +5 lines)
Lines 18-24 Link Here
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
use Test::More tests => 76;
21
use Test::More tests => 77;
22
use Test::MockModule;
22
use Test::MockModule;
23
use Test::Warn;
23
use Test::Warn;
24
24
Lines 133-140 is( $messages->[0]->{status}, 'pending', 'EnqueueLetter stores the status pendin Link Here
133
133
134
134
135
# SendQueuedMessages
135
# SendQueuedMessages
136
my $messages_processed = C4::Letters::SendQueuedMessages();
136
my $messages_processed = C4::Letters::SendQueuedMessages( { type => 'email' });
137
is($messages_processed, 1, 'all queued messages processed');
137
is($messages_processed, 0, 'No queued messaged process if type limit passed with unused type');
138
$messages_processed = C4::Letters::SendQueuedMessages( { type => 'sms' });
139
is($messages_processed, 1, 'all queued messages processed, found correct number of messages with type limit');
138
$messages = C4::Letters::GetQueuedMessages({ borrowernumber => $borrowernumber });
140
$messages = C4::Letters::GetQueuedMessages({ borrowernumber => $borrowernumber });
139
is(
141
is(
140
    $messages->[0]->{status},
142
    $messages->[0]->{status},
141
- 

Return to bug 19955