Making WordPress.org

Changeset 11786


Ignore:
Timestamp:
04/25/2022 10:24:36 PM (3 years ago)
Author:
iandunn
Message:

Props: Pop giver from array to avoid lookup failure.

The users are indexed by Slack ID now, rather than sequentially.

See https://wordpress.slack.com/archives/C0FRG66LR/p1650921688316429?thread_ts=1650918540.182309&cid=C0FRG66LR

File:
1 edited

Legend:

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

    r11783 r11786  
    7171    }
    7272
    73     $giver_user          = map_slack_users_to_wporg( array( $request->event->user ) )[0];
     73    $giver_user          = map_slack_users_to_wporg( array( $request->event->user ) );
     74    $giver_user          = array_pop( $giver_user );
    7475    $recipient_slack_ids = get_recipient_slack_ids( $request->event->blocks );
     76
     77    // You have to have a w.org account to have a Slack account, so this should always be populated.
     78    // The 'Received props from @...' would be broken if the giver can't be found.
     79    // Don't throw if a recipient lookup fails, since we still want other recipients to get props.
     80    if ( empty( $giver_user ) ) {
     81        throw new Exception( 'w.org user lookup for slack ID '. $request->event->user .' failed' );
     82    }
    7583
    7684    if ( empty( $recipient_slack_ids ) ) {
Note: See TracChangeset for help on using the changeset viewer.