[2ea88f42] Keine neuen Commits in dieser Session.
Keine neuen Commits in dieser Session.
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
import sys
|
||||
import os
|
||||
from superoffice_client import SuperOfficeClient
|
||||
import os
|
||||
import sys
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Load .env BEFORE importing SuperOfficeClient to ensure settings are correctly initialized
|
||||
load_dotenv(os.path.join(os.path.dirname(__file__), "../.env"), override=True)
|
||||
|
||||
from superoffice_client import SuperOfficeClient
|
||||
|
||||
# Configuration
|
||||
WEBHOOK_NAME = "Gemini Connector Production"
|
||||
TARGET_URL = f"https://floke-ai.duckdns.org/connector/webhook?token={os.getenv('WEBHOOK_TOKEN', 'changeme')}"
|
||||
TARGET_URL = f"https://floke-ai.duckdns.org/connector/webhook?token={os.getenv('WEBHOOK_TOKEN')}"
|
||||
EVENTS = [
|
||||
"contact.created",
|
||||
"contact.changed",
|
||||
@@ -14,14 +20,17 @@ EVENTS = [
|
||||
]
|
||||
|
||||
def register():
|
||||
load_dotenv("../.env")
|
||||
print("🚀 Initializing SuperOffice Client...")
|
||||
print(f"🚀 Initializing SuperOffice Client for Production...")
|
||||
try:
|
||||
client = SuperOfficeClient()
|
||||
except Exception as e:
|
||||
print(f"❌ Failed to connect: {e}")
|
||||
return
|
||||
|
||||
if not client.access_token:
|
||||
print("❌ Auth failed. Check SO_CLIENT_ID and SO_REFRESH_TOKEN in .env")
|
||||
return
|
||||
|
||||
print("🔎 Checking existing webhooks...")
|
||||
webhooks = client._get("Webhook")
|
||||
|
||||
@@ -32,17 +41,26 @@ def register():
|
||||
|
||||
# Check if URL matches
|
||||
if wh['TargetUrl'] != TARGET_URL:
|
||||
print(f" ⚠️ URL Mismatch! Deleting old webhook...")
|
||||
# Warning: _delete is not implemented in generic client yet, skipping auto-fix
|
||||
print(f" ⚠️ URL Mismatch!")
|
||||
print(f" Existing: {wh['TargetUrl']}")
|
||||
print(f" New: {TARGET_URL}")
|
||||
print(" Please delete it manually via API or extend client.")
|
||||
else:
|
||||
print(f" ✅ Webhook is up to date.")
|
||||
return
|
||||
|
||||
print(f"✨ Registering new webhook: {WEBHOOK_NAME}")
|
||||
|
||||
webhook_secret = os.getenv('WEBHOOK_SECRET')
|
||||
if not webhook_secret:
|
||||
print("❌ Error: WEBHOOK_SECRET missing in .env")
|
||||
return
|
||||
|
||||
payload = {
|
||||
"Name": WEBHOOK_NAME,
|
||||
"Events": EVENTS,
|
||||
"TargetUrl": TARGET_URL,
|
||||
"Secret": "changeme", # Used for signature calculation by SO
|
||||
"Secret": webhook_secret, # Used for signature calculation by SO
|
||||
"State": "Active",
|
||||
"Type": "Webhook"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user