@@ -6014,76 +6014,81 @@ __nccwpck_require__.r(__webpack_exports__);
6014
6014
6015
6015
6016
6016
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 } ) ;
6027
6027
const initialConfig = {
6028
6028
username : email ,
6029
- realm
6030
- }
6031
- const config = { }
6029
+ realm,
6030
+ } ;
6031
+ const config = { } ;
6032
6032
if ( apiKey ) {
6033
- Object . assign ( config , initialConfig , { apiKey } )
6033
+ Object . assign ( config , initialConfig , { apiKey } ) ;
6034
6034
} 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 ;
6037
6037
}
6038
- if ( type === 'private' ) {
6038
+
6039
+ if ( type === "private" ) {
6039
6040
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 ) ) ;
6042
6043
if ( containsUserIds ) {
6043
- to = to . map ( ( item ) => parseInt ( item ) )
6044
+ to = to . map ( ( item ) => Number . parseInt ( item ) ) ;
6044
6045
}
6045
6046
}
6046
- } else if ( type === ' stream' ) {
6047
+ } else if ( type === " stream" ) {
6047
6048
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 ;
6050
6051
}
6051
- if ( to . match ( allNumericRegex ) ) {
6052
- to = parseInt ( to )
6052
+
6053
+ if ( allNumericRegex . test ( to ) ) {
6054
+ to = Number . parseInt ( to ) ;
6053
6055
}
6054
6056
} 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 ;
6057
6059
}
6060
+
6058
6061
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 ) ;
6060
6063
// Send a message
6061
- const params = {
6064
+ const parameters = {
6062
6065
to,
6063
6066
type,
6064
6067
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" ) {
6069
6072
// 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 } ` ) ;
6071
6074
} 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 ) ) ;
6074
6079
}
6075
6080
} catch ( error ) {
6076
- ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . setFailed ) ( error )
6081
+ ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . setFailed ) ( error ) ;
6077
6082
}
6078
6083
}
6079
6084
6080
- ; ( async ( ) => {
6085
+ ( async ( ) => {
6081
6086
try {
6082
- await run ( )
6087
+ await run ( ) ;
6083
6088
} catch ( error ) {
6084
- ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . setFailed ) ( error )
6089
+ ( 0 , _actions_core__WEBPACK_IMPORTED_MODULE_0__ . setFailed ) ( error ) ;
6085
6090
}
6086
- } ) ( )
6091
+ } ) ( ) ;
6087
6092
6088
6093
} ) ( ) ;
6089
6094
0 commit comments