Skip to content

Commit acb206c

Browse files
committed
progress
1 parent 21d250b commit acb206c

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

component.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@
2525
"auth_uri": "https://login.microsoftonline.com/common/oauth2/v2.0/authorize",
2626
"token_uri": "https://login.microsoftonline.com/common/oauth2/v2.0/token",
2727
"scopes": [
28-
"openid", "offline_access", "User.Read", "Contacts.Read", "Profile", "Calendars.ReadWrite"
28+
"openid",
29+
"offline_access",
30+
"User.Read",
31+
"Contacts.Read",
32+
"Profile",
33+
"Calendars.ReadWrite"
2934
]
3035
}
3136
},
@@ -49,6 +54,14 @@
4954
"out": "./lib/schemas/checkAvailability.out.json"
5055
}
5156
},
57+
"findNextAvailableTime": {
58+
"title": "Find Next Available Time",
59+
"main": "./lib/actions/findNextAvailableTime.js",
60+
"metadata": {
61+
"in": "./lib/schemas/findNextAvailableTime.in.json",
62+
"out": "./lib/schemas/findNextAvailableTime.out.json"
63+
}
64+
},
5265
"createEvent": {
5366
"title": "Create Event",
5467
"main": "./lib/actions/createEvent.js",
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const elasticio = require('elasticio-node');
2+
const messages = elasticio.messages;
3+
const ApiClient = require('../apiClient');
4+
5+
module.exports.process = processAction;
6+
7+
async function processAction(msg, cfg) {
8+
try {
9+
const client = ApiClient(cfg);
10+
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}'`);
13+
if (events.value.length) {
14+
time = events.value.pop().end.dateTime
15+
}
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+
}

0 commit comments

Comments
 (0)