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

(-)a/Koha/REST/V1/Patrons.pm (-1 / +4 lines)
Lines 116-122 sub add { Link Here
116
116
117
                my $patron = Koha::Patron->new_from_api($body)->store;
117
                my $patron = Koha::Patron->new_from_api($body)->store;
118
118
119
                if ( $c->req->headers->header('x-koha-welcome') ) {
119
                my $overrides = $c->stash('koha.overrides');
120
                if ( $overrides->{welcome_yes}
121
                    || ( C4::Context->preference("AutoEmailNewUser") && !$overrides->{welcome_no} ) )
122
                {
120
123
121
                    # if we manage to find a valid email address, send notice
124
                    # if we manage to find a valid email address, send notice
122
                    if ( $patron->notice_email_address ) {
125
                    if ( $patron->notice_email_address ) {
(-)a/api/v1/swagger/paths/patrons.yaml (-3 / +9 lines)
Lines 405-415 Link Here
405
        required: true
405
        required: true
406
        schema:
406
        schema:
407
          $ref: "../swagger.yaml#/definitions/patron"
407
          $ref: "../swagger.yaml#/definitions/patron"
408
      - name: x-koha-welcome
408
      - name: x-koha-override
409
        in: header
409
        in: header
410
        required: false
410
        required: false
411
        description: If set to 'email' triggers the sending of a welcome email
411
        description: Overrides list sent as a request header
412
        type: string
412
        type: array
413
        items:
414
          type: string
415
          enum:
416
            - welcome_yes
417
            - welcome_no
418
        collectionFormat: csv
413
    consumes:
419
    consumes:
414
      - application/json
420
      - application/json
415
    produces:
421
    produces:
(-)a/t/db_dependent/api/v1/patrons.t (-2 / +3 lines)
Lines 398-405 subtest 'add() tests' => sub { Link Here
398
        # Set a date-time field
398
        # Set a date-time field
399
        $newpatron->{last_seen} = output_pref({ dt => dt_from_string->add( days => -1 ), dateformat => 'rfc3339' });
399
        $newpatron->{last_seen} = output_pref({ dt => dt_from_string->add( days => -1 ), dateformat => 'rfc3339' });
400
400
401
        t::lib::Mocks::mock_preference( 'AutoEmailNewUser', 0 );
401
        $letter_enqueued = 0;
402
        $letter_enqueued = 0;
402
        $t->post_ok("//$userid:$password@/api/v1/patrons" => { 'x-koha-welcome' => 'email' } => json => $newpatron)
403
        $t->post_ok(
404
            "//$userid:$password@/api/v1/patrons" => { 'x-koha-override' => 'welcome_yes' } => json => $newpatron )
403
          ->status_is(201, 'Patron created successfully')
405
          ->status_is(201, 'Patron created successfully')
404
          ->header_like(
406
          ->header_like(
405
            Location => qr|^\/api\/v1\/patrons/\d*|,
407
            Location => qr|^\/api\/v1\/patrons/\d*|,
406
- 

Return to bug 33690