Changeset 12396 for sites/trunk/common/includes/slack/props/lib.php
- Timestamp:
- 02/13/2023 11:31:27 PM (3 years ago)
- File:
-
- 1 edited
-
sites/trunk/common/includes/slack/props/lib.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/common/includes/slack/props/lib.php
r11927 r12396 8 8 * Adds props in Slack to w.org profiles. 9 9 * 10 * Receives webhook notifications for all new messages in `#props` ,10 * Receives webhook notifications for all new messages in `#props`. See `dotorg/slack/props.php` for the caller. 11 11 */ 12 12 function handle_props_message( object $request ) : string { … … 87 87 /** 88 88 * Parse the mentioned Slack user IDs from a message event. 89 *90 * This assumes that the app is configured to escape usernames.91 89 */ 92 90 function get_recipient_slack_ids( array $blocks ) : array { … … 95 93 foreach ( $blocks as $block ) { 96 94 foreach ( $block->elements as $element ) { 97 foreach ( $element->elements as $inner_element ) { 98 if ( 'user' !== $inner_element->type ) { 99 continue; 100 } 101 102 $ids[] = $inner_element->user_id; 103 } 95 $ids = array_merge( $ids, get_user_ids_from_element( $element ) ); 104 96 } 105 97 } … … 107 99 return array_unique( $ids ); 108 100 } 101 102 /** 103 * Recursively parse any mentioned Slack user IDs from a message element. 104 * 105 * This assumes that the app is configured to escape usernames. 106 */ 107 function get_user_ids_from_element( object $element ) : array { 108 $ids = array(); 109 110 if ( 'user' === $element->type ) { 111 $ids[] = $element->user_id; 112 } 113 114 if ( isset( $element->elements ) ) { 115 foreach ( $element->elements as $inner_element ) { 116 $ids = array_merge( $ids, get_user_ids_from_element( $inner_element ) ); 117 } 118 } 119 120 return $ids; 121 } 122 109 123 110 124 /**
Note: See TracChangeset
for help on using the changeset viewer.