File tree Expand file tree Collapse file tree 1 file changed +36
-3
lines changed
src/support/slack/actions Expand file tree Collapse file tree 1 file changed +36
-3
lines changed Original file line number Diff line number Diff line change 1010 * governing permissions and limitations under the License.
1111 */
1212
13- export default function approveOrg ( ) {
14- return async ( { ack } ) => {
15- await ack ( ) ;
13+ import { Blocks , Message } from 'slack-block-builder' ;
14+
15+ export default function approveOrg ( lambdaContext ) {
16+ const { log } = lambdaContext ;
17+
18+ return async ( { ack, body, respond } ) => {
19+ try {
20+ const { message = { } , user } = body ;
21+ const { blocks } = message ;
22+
23+ log . info ( JSON . stringify ( body ) ) ;
24+
25+ await ack ( ) ; // slack expects acknowledgement within 3s
26+
27+ const replyText = Message ( )
28+ . blocks (
29+ Blocks . Section ( )
30+ . blockId ( blocks [ 0 ] ?. block_id )
31+ . text ( blocks [ 0 ] ?. text ?. text ) ,
32+ Blocks . Section ( ) . text ( `Approved by @${ user . username } :checked:` ) ,
33+ )
34+ . buildToObject ( ) ;
35+
36+ const reply = {
37+ ...replyText ,
38+ text : blocks [ 0 ] ?. text ?. text ,
39+ replace_original : true ,
40+ } ;
41+
42+ log . info ( `Responding site candidate ignore with: ${ JSON . stringify ( reply ) } ` ) ;
43+
44+ await respond ( reply ) ;
45+ } catch ( e ) {
46+ log . error ( 'Error occurred while acknowledging site candidate ignore' , e ) ;
47+ throw e ;
48+ }
1649 } ;
1750}
You can’t perform that action at this time.
0 commit comments