telegram_notes_bot/event_alerts.js
2021-02-27 10:18:43 +01:00

25 lines
702 B
JavaScript

// Create as JS Backend note and add these attributes:
// ~targetTemplateEvent=@event template (this note is described below)
// #customRequestHandler=event_alerts
// Create another note (event template) with this promoted attributes:
// startTime
// Optionally add:
// endTime, location
const {req, res} = api;
const targetTemplate = await api.currentNote.getRelationValue("targetTemplateEvent");
const events = await api.getNotesWithLabel("template", targetTemplate);
let eventsData = [];
for (const event of events) {
const attr = await event.getAttribute("label", "startTime");
eventsData.push({
name: event.title,
startTime: attr.value
});
}
res.send(eventsData);