diff --git a/infra/n8n/ocsentinel-weekly-organization-reports.json b/infra/n8n/ocsentinel-weekly-organization-reports.json index dc03fbf..d93dc2d 100644 --- a/infra/n8n/ocsentinel-weekly-organization-reports.json +++ b/infra/n8n/ocsentinel-weekly-organization-reports.json @@ -19,12 +19,28 @@ "parameters": { "operation": "executeQuery", "query": "INSERT INTO ocsentinel.weekly_organization_report (organization_id, organization_name, period_start_utc, period_end_utc, device_count, warning_count, critical_count, total_events, unique_ips, cve_total, cve_critical, report_html, summary)\nVALUES ($1, $2, $3::timestamptz, $4::timestamptz, $5, $6, $7, $8, $9, $10, $11, $12, $13::jsonb)\nON CONFLICT (organization_id, period_start_utc) DO UPDATE SET organization_name=EXCLUDED.organization_name, period_end_utc=EXCLUDED.period_end_utc, generated_at=now(), device_count=EXCLUDED.device_count, warning_count=EXCLUDED.warning_count, critical_count=EXCLUDED.critical_count, total_events=EXCLUDED.total_events, unique_ips=EXCLUDED.unique_ips, cve_total=EXCLUDED.cve_total, cve_critical=EXCLUDED.cve_critical, report_html=EXCLUDED.report_html, summary=EXCLUDED.summary\nRETURNING id;", "options": { "queryReplacement": "={{ [$json.organizationId, $json.organizationName, $json.periodStartUtc, $json.periodEndUtc, $json.deviceCount, $json.warningCount, $json.criticalCount, $json.totalEvents, $json.uniqueIps, $json.cveTotal, $json.cveCritical, $json.reportHtml, $json.summaryJson] }}" } }, "id": "store-weekly-reports", "name": "Store Weekly Organization Reports", "type": "n8n-nodes-base.postgres", "typeVersion": 2.5, "position": [1080, 300], "credentials": { "postgres": { "id": "WkjY0kIF3kHvREys", "name": "OCSentinel PostgreSQL" } } + }, + { + "parameters": { + "fromEmail": "donotreply@officecom.biz", + "toEmail": "lg@officecom.it", + "subject": "=OCSentinel Wochenbericht - {{ $('Build Organization HTML Reports').item.json.organizationName }}", + "html": "={{ $('Build Organization HTML Reports').item.json.reportHtml }}", + "options": { "appendAttribution": false } + }, + "id": "send-weekly-report-email", + "name": "Send Weekly Organization Report", + "type": "n8n-nodes-base.emailSend", + "typeVersion": 2.1, + "position": [1330, 300], + "credentials": { "smtp": { "id": "vafGYgYzM9SbxQbW", "name": "SMTP account" } } } ], "connections": { "Every Monday 07:20": { "main": [[{ "node": "Load Latest Device Reports", "type": "main", "index": 0 }]] }, "Load Latest Device Reports": { "main": [[{ "node": "Build Organization HTML Reports", "type": "main", "index": 0 }]] }, - "Build Organization HTML Reports": { "main": [[{ "node": "Store Weekly Organization Reports", "type": "main", "index": 0 }]] } + "Build Organization HTML Reports": { "main": [[{ "node": "Store Weekly Organization Reports", "type": "main", "index": 0 }]] }, + "Store Weekly Organization Reports": { "main": [[{ "node": "Send Weekly Organization Report", "type": "main", "index": 0 }]] } }, "settings": { "executionOrder": "v1", "timezone": "Europe/Berlin" }, "active": true,