@@ -6014,76 +6014,81 @@ __nccwpck_require__.r(__webpack_exports__);
60146014
60156015
60166016
6017- const allNumericRegex = / ^ [ 0 - 9 ] + $ /
6018-
6019- async function run ( ) {
6020- const email = ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . getInput ) ( ' email' , { required : true } )
6021- const apiKey = ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . getInput ) ( ' api-key' , { required : true } )
6022- const realm = ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . getInput ) ( ' organization-url' , { required : true } )
6023- let to = ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . getInput ) ( 'to' , { required : true } )
6024- const type = ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . getInput ) ( ' type' , { required : true } )
6025- const topic = ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . getInput ) ( ' topic' , { required : false } )
6026- const content = ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . getInput ) ( ' content' , { required : true } )
6017+ const allNumericRegex = / ^ \d + $ / ;
6018+
6019+ async function run ( ) {
6020+ const email = ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . getInput ) ( " email" , { required : true } ) ;
6021+ const apiKey = ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . getInput ) ( " api-key" , { required : true } ) ;
6022+ const realm = ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . getInput ) ( " organization-url" , { required : true } ) ;
6023+ let to = ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . getInput ) ( "to" , { required : true } ) ;
6024+ const type = ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . getInput ) ( " type" , { required : true } ) ;
6025+ const topic = ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . getInput ) ( " topic" , { required : false } ) ;
6026+ const content = ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . getInput ) ( " content" , { required : true } ) ;
60276027 const initialConfig = {
60286028 username : email ,
6029- realm
6030- }
6031- const config = { }
6029+ realm,
6030+ } ;
6031+ const config = { } ;
60326032 if ( apiKey ) {
6033- Object . assign ( config , initialConfig , { apiKey } )
6033+ Object . assign ( config , initialConfig , { apiKey } ) ;
60346034 } else {
6035- ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . setFailed ) ( ' api-key is mandatory in order to interact with the Zulip API.' )
6036- return
6035+ ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . setFailed ) ( " api-key is mandatory in order to interact with the Zulip API." ) ;
6036+ return ;
60376037 }
6038- if ( type === 'private' ) {
6038+
6039+ if ( type === "private" ) {
60396040 if ( to ) {
6040- to = to . split ( ',' )
6041- const containsUserIds = to . every ( ( item ) => item . match ( allNumericRegex ) )
6041+ to = to . split ( "," ) ;
6042+ const containsUserIds = to . every ( ( item ) => item . match ( allNumericRegex ) ) ;
60426043 if ( containsUserIds ) {
6043- to = to . map ( ( item ) => parseInt ( item ) )
6044+ to = to . map ( ( item ) => Number . parseInt ( item ) ) ;
60446045 }
60456046 }
6046- } else if ( type === ' stream' ) {
6047+ } else if ( type === " stream" ) {
60476048 if ( ! topic ) {
6048- ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . setFailed ) ( 'topic is mandatory when type is "stream".' )
6049- return
6049+ ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . setFailed ) ( 'topic is mandatory when type is "stream".' ) ;
6050+ return ;
60506051 }
6051- if ( to . match ( allNumericRegex ) ) {
6052- to = parseInt ( to )
6052+
6053+ if ( allNumericRegex . test ( to ) ) {
6054+ to = Number . parseInt ( to ) ;
60536055 }
60546056 } else {
6055- ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . setFailed ) ( ' type must be one of: private, stream.' )
6056- return
6057+ ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . setFailed ) ( " type must be one of: private, stream." ) ;
6058+ return ;
60576059 }
6060+
60586061 try {
6059- const client = await zulip_js__WEBPACK_IMPORTED_MODULE_1___default ( ) ( config )
6062+ const client = await zulip_js__WEBPACK_IMPORTED_MODULE_1___default ( ) ( config ) ;
60606063 // Send a message
6061- const params = {
6064+ const parameters = {
60626065 to,
60636066 type,
60646067 topic,
6065- content
6066- }
6067- const response = await client . messages . send ( params )
6068- if ( response . result === ' success' ) {
6068+ content,
6069+ } ;
6070+ const response = await client . messages . send ( parameters ) ;
6071+ if ( response . result === " success" ) {
60696072 // OK!
6070- ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . info ) ( `Message successfully send with id: ${ response . id } ` )
6073+ ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . info ) ( `Message successfully send with id: ${ response . id } ` ) ;
60716074 } else {
6072- const errorMessage = response . code ? `${ response . code } : ${ response . msg } ` : response . msg
6073- ; ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . setFailed ) ( new Error ( errorMessage ) )
6075+ const errorMessage = response . code
6076+ ? `${ response . code } : ${ response . msg } `
6077+ : response . msg ;
6078+ ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . setFailed ) ( new Error ( errorMessage ) ) ;
60746079 }
60756080 } catch ( error ) {
6076- ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . setFailed ) ( error )
6081+ ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . setFailed ) ( error ) ;
60776082 }
60786083}
60796084
6080- ; ( async ( ) => {
6085+ ( async ( ) => {
60816086 try {
6082- await run ( )
6087+ await run ( ) ;
60836088 } catch ( error ) {
6084- ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . setFailed ) ( error )
6089+ ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . setFailed ) ( error ) ;
60856090 }
6086- } ) ( )
6091+ } ) ( ) ;
60876092
60886093} ) ( ) ;
60896094
0 commit comments