brain/user-scripts/create_meeting_note.js

40 lines
1.5 KiB
JavaScript

// Templater user script — called via tp.user.create_meeting_note(tp)
// Returns { content, fileName } so the template can rename + move the file
async function create_meeting_note(tp) {
const path = require('path');
const scriptsDir = path.join(app.vault.adapter.basePath, 'scripts', 'lib');
const { getCalendarEvents, formatEventChoice } = require(path.join(scriptsDir, 'o365-calendar.js'));
const { resolveAttendees } = require(path.join(scriptsDir, 'person-matcher.js'));
const { buildMeetingFromEvent, buildMeetingNote, buildFileName } = require(path.join(scriptsDir, 'meeting-builder.js'));
// Fetch events
const meetings = await getCalendarEvents(7);
if (meetings.length === 0) {
new Notice('Keine Kalender-Events in den nächsten 7 Tagen gefunden.');
return null;
}
// Build selection list
const choices = meetings.map(m => formatEventChoice(m));
const selected = await tp.system.suggester(choices, meetings);
if (!selected) return null;
// Resolve attendees against vault persons
const resolvedAttendees = resolveAttendees(selected.attendees);
// Build meeting data with series detection + agenda
const meetingData = buildMeetingFromEvent(selected, resolvedAttendees);
// Build note content and filename
const noteContent = buildMeetingNote(meetingData);
const fileName = buildFileName(meetingData.date, meetingData.title);
return { content: noteContent, fileName: fileName.replace('.md', '') };
}
module.exports = create_meeting_note;