Making WordPress.org

Changeset 7757


Ignore:
Timestamp:
10/22/2018 05:43:33 PM (6 years ago)
Author:
vedjain
Message:

Slack: Use slack_dm instead of manual curl request.

slack_dm is used elsewhere in the project as well, so using a common library to make future maintainence easier.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wcorg-misc.php

    r7736 r7757  
    452452
    453453    $message = array(
    454         "attachments" => array(
    455             array(
    456                 "fallback" => $text,
    457                 "color" => "#ff0000",
    458                 "pretext" => "Error on \"$file:$line\" ",
    459                 "author_name" => $domain,
    460                 "text" => $text,
    461             ),
    462         ),
     454        "fallback" => $text,
     455        "color" => "#ff0000",
     456        "pretext" => "Error on \"$file:$line\" ",
     457        "author_name" => $domain,
     458        "text" => $text,
    463459    );
    464 
    465     $data = json_encode( $message );
    466 
    467     $req = curl_init( SLACK_ERROR_REPORT_URL );
    468     curl_setopt( $req, CURLOPT_HTTPHEADER, array( "Content-type: application/json" ) );
    469     curl_setopt( $req, CURLOPT_POST, true );
    470     curl_setopt( $req, CURLOPT_POSTFIELDS, $data );
    471 
    472     curl_exec( $req );
    473 
     460    require_once '/home/api/public_html/includes/slack-config.php';
     461    $send = new \Dotorg\Slack\Send( SLACK_ERROR_REPORT_URL );
     462    $send->add_attachment( $message );
     463
     464    // For now
     465    $send->send( 'vedanshu' );
    474466    return false;
    475467}
Note: See TracChangeset for help on using the changeset viewer.