Changeset 11785
- Timestamp:
- 04/25/2022 07:56:34 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/dotorg/slack/props.php
r11762 r11785 2 2 3 3 /* 4 * This endpoint receives payloads from the `/props` slash command in `#props`. 5 * 6 * To manage, browse to https://wordpress.slack.com/apps/manage/custom-integrations > Slash Commands > `/props`. 4 * This endpoint receives requests from the `#props - production` app. 7 5 */ 8 6 … … 13 11 14 12 namespace Dotorg\Slack\Props { 13 use Exception; 14 use function Dotorg\Slack\{ is_valid_request }; 15 16 require dirname( __DIR__, 2 ) . '/includes/slack/helpers.php'; 15 17 require dirname( __DIR__, 2 ) . '/includes/slack/props/lib.php'; 16 18 … … 29 31 30 32 $hash = md5( strtolower( trim( $email ) ) ); 33 31 34 return sprintf( 'https://secure.gravatar.com/avatar/%s?s=96d=mm&r=G&%s', $hash, time() ); 32 35 } 33 36 34 37 if ( constant( __NAMESPACE__ . '\\WEBHOOK_TOKEN' ) === $_POST['token'] ) { 35 echo run( $_POST ); 38 die( run( $_POST ) ); 39 } 40 41 try { 42 $result = ''; 43 $request_body_raw = file_get_contents( 'php://input' ); 44 $request_body_parsed = json_decode( $request_body_raw ); 45 $valid_request = is_valid_request( APP_ID, APP_SIGNING_SECRET, getallheaders(), $request_body_raw ); 46 47 if ( $valid_request ) { 48 // Replying with the challenge verifies this handler to Slack. 49 $result = $request_body_parsed->challenge ?? handle_props_message( $request_body_parsed ); 50 } 51 52 die( $result ); 53 54 } catch ( Exception $exception ) { 55 trigger_error( $exception->getMessage(), E_USER_WARNING ); 36 56 } 37 57 }
Note: See TracChangeset
for help on using the changeset viewer.