telegram_notes_bot/event_alerts.js

25 lines
702 B
JavaScript
Raw Normal View History

2021-02-27 09:18:43 +00:00
// 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);