Add calendar sync step files: API, cron, and event handlers for bidirectional Advoware-Google Calendar sync
This commit is contained in:
49
bitbylaw/steps/advoware_cal_sync/calendar_sync_api_step.py
Normal file
49
bitbylaw/steps/advoware_cal_sync/calendar_sync_api_step.py
Normal file
@@ -0,0 +1,49 @@
|
||||
import json
|
||||
|
||||
config = {
|
||||
'type': 'api',
|
||||
'name': 'Calendar Sync API Trigger',
|
||||
'description': 'API-Endpunkt zum manuellen Auslösen des Calendar Sync',
|
||||
'path': '/advoware/calendar/sync',
|
||||
'method': 'POST',
|
||||
'emits': ['calendar.sync.triggered']
|
||||
}
|
||||
|
||||
async def handler(req, context):
|
||||
try:
|
||||
# Konfiguration aus Request-Body
|
||||
body = req.get('body', {})
|
||||
full_content = body.get('full_content', True)
|
||||
|
||||
print(f"Calendar Sync API aufgerufen, full_content: {full_content}")
|
||||
|
||||
# Emit Event für den Sync
|
||||
await context.emit({
|
||||
"topic": "calendar.sync.triggered",
|
||||
"data": {
|
||||
"body": {
|
||||
"full_content": full_content,
|
||||
"triggered_by": "api"
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
'status': 200,
|
||||
'body': {
|
||||
'status': 'triggered',
|
||||
'message': 'Calendar sync wurde ausgelöst',
|
||||
'full_content': full_content,
|
||||
'triggered_by': 'api'
|
||||
}
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
context.logger.error(f"Fehler beim API-Trigger: {e}")
|
||||
return {
|
||||
'status': 500,
|
||||
'body': {
|
||||
'error': 'Internal server error',
|
||||
'details': str(e)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user