Making WordPress.org


Ignore:
Timestamp:
09/12/2018 03:04:38 AM (7 years ago)
Author:
dd32
Message:

Slack: When comparing a slack user to the user whitelist, determine the user by comparing the Slack ID to our slack database prior to using the deprecated user_name slack field.

This should allow users who sign up after a certain date to be whitelisted for /announce and /here commands.

See #3799.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/common/includes/slack/announce/lib.php

    r5494 r7661  
    5959
    6060function run( $data ) {
    61     $user = $data['user_name'];
     61    global $wpdb;
     62
    6263    $channel = $data['channel_name'];
     64    $user = false;
     65
     66    // Find the user_login for the Slack user_id
     67    if ( isset( $data['user_id'] ) ) {
     68        $wp_user_id = $wpdb->get_var( $wpdb->prepare(
     69            "SELECT user_id FROM slack_users WHERE slack_id = %s",
     70            $data['user_id']
     71        ) );
     72        if ( $user = get_user_by( 'id', $wp_user_id ) ) {
     73            $user = $user->user_login;
     74        }
     75    }
     76    // Default back to the historical 'user_name' Slack field.
     77    if ( ! $user ) {
     78        $user = $data['user_name'];
     79    }
    6380
    6481    if ( empty( $data['text'] ) ) {
     
    114131        $send->set_icon( call_user_func( $get_avatar, $data['user_name'], $data['user_id'], $data['team_id'] ) );
    115132    }
    116    
     133
    117134    // By sending the channel ID, we can post to private groups.
    118135    $send->send( $data['channel_id'] );
Note: See TracChangeset for help on using the changeset viewer.