File tree Expand file tree Collapse file tree 2 files changed +15
-29
lines changed Expand file tree Collapse file tree 2 files changed +15
-29
lines changed Original file line number Diff line number Diff line change @@ -5,18 +5,11 @@ const ApiClient = require('../apiClient');
5
5
module . exports . process = processAction ;
6
6
7
7
async function processAction ( msg , cfg ) {
8
- try {
9
- const client = ApiClient ( cfg ) ;
10
- let currentTime = msg . body . time || ( new Date ( ) ) . toISOString ( ) ;
11
- let events = await client . get ( `/me/events?$filter=start/dateTime le '${ currentTime } '
12
- and end/dateTime ge '${ currentTime } '` ) ;
13
- this . emit ( 'data' , messages . newMessageWithBody ( {
14
- available : ! events . value . length
15
- } ) ) ;
16
- } catch ( e ) {
17
- console . log ( e . error ) ;
18
- this . emit ( 'error' , e ) ;
19
- } finally {
20
- this . emit ( 'end' ) ;
21
- }
8
+ const client = ApiClient ( cfg ) ;
9
+ const currentTime = msg . body . time || ( new Date ( ) ) . toISOString ( ) ;
10
+ const events = await client . get ( `/me/events?$filter=start/dateTime le '${ currentTime } '
11
+ and end/dateTime ge '${ currentTime } '` ) ;
12
+ return messages . newMessageWithBody ( {
13
+ available : ! events . value . length
14
+ } ) ;
22
15
}
Original file line number Diff line number Diff line change @@ -5,22 +5,15 @@ const ApiClient = require('../apiClient');
5
5
module . exports . process = processAction ;
6
6
7
7
async function processAction ( msg , cfg ) {
8
- try {
9
8
const client = ApiClient ( cfg ) ;
10
9
let time = msg . body . time || ( new Date ( ) ) . toISOString ( ) ;
11
- let events = await client . get ( `/me/events?$filter=start/dateTime le '${ time } '
12
- and end/dateTime ge '${ time } '` ) ;
10
+ const events = await client . get ( `/me/events?$filter=start/dateTime le '${ time } '
11
+ and end/dateTime ge '${ time } '` ) ;
13
12
if ( events . value . length ) {
14
- time = events . value . pop ( ) . end . dateTime
13
+ time = events . value . pop ( ) . end . dateTime ;
15
14
}
16
- this . emit ( 'data' , messages . newMessageWithBody ( {
17
- time : time ,
18
- subject : msg . body . subject
19
- } ) ) ;
20
- } catch ( e ) {
21
- console . log ( e . error ) ;
22
- this . emit ( 'error' , e ) ;
23
- } finally {
24
- this . emit ( 'end' ) ;
25
- }
26
- }
15
+ return messages . newMessageWithBody ( {
16
+ time,
17
+ subject : msg . body . subject
18
+ } ) ;
19
+ }
You can’t perform that action at this time.
0 commit comments