Add calendar sync step files: API, cron, and event handlers for bidirectional Advoware-Google Calendar sync
This commit is contained in:
37
bitbylaw/steps/advoware_cal_sync/calendar_sync_cron_step.py
Normal file
37
bitbylaw/steps/advoware_cal_sync/calendar_sync_cron_step.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import json
|
||||
|
||||
config = {
|
||||
'type': 'cron',
|
||||
'name': 'Calendar Sync Cron Job',
|
||||
'description': 'Führt den Calendar Sync alle 15 Minuten automatisch aus',
|
||||
'cron': '*/15 * * * *', # Alle 15 Minuten
|
||||
'emits': ['calendar.sync.triggered']
|
||||
}
|
||||
|
||||
async def handler(event, context):
|
||||
try:
|
||||
context.logger.info("Calendar Sync Cron: Starte automatische Synchronisation alle 15 Minuten")
|
||||
|
||||
# Emit Event für den Sync
|
||||
await context.emit({
|
||||
"topic": "calendar.sync.triggered",
|
||||
"data": {
|
||||
"body": {
|
||||
"full_content": True, # Cron verwendet immer volle Details
|
||||
"triggered_by": "cron"
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
context.logger.info("Calendar Sync Cron: Event wurde emittiert")
|
||||
return {
|
||||
'status': 'completed',
|
||||
'triggered_by': 'cron'
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
context.logger.error(f"Fehler beim Cron-Job: {e}")
|
||||
return {
|
||||
'status': 'error',
|
||||
'error': str(e)
|
||||
}
|
||||
Reference in New Issue
Block a user