Add optional AI generation, MQTT, OAuth refresh and calendar recurrence

This commit is contained in:
Pigway
2026-10-08 23:44:07 +08:00
parent 69a0841868
commit 8209aadbb8
24 changed files with 1113 additions and 37 deletions
@@ -2,6 +2,7 @@
import json
import re
import time
from pathlib import Path
from urllib.parse import urlencode, urlsplit
@@ -30,6 +31,29 @@ class CloudDrives:
for key in ["access_token", "refresh_token", "client_secret"]:
if value.get(key):
self.settings.additional_secrets.append(value[key])
if (
value.get("expires_at")
and float(value["expires_at"]) <= time.time() + 60
):
if source.credential_env:
raise FlowError(
E.CONFIG_REQUIRED,
"Environment OAuth token expired; update its secret",
409,
)
from pigway_frame_flow.providers.oauth import OAuthTokens
if not hasattr(self.photos, "oauth_tokens"):
self.photos.oauth_tokens = OAuthTokens(
self.settings, self.photos.assets
)
with self.photos.oauth_tokens.lock:
latest = json.loads(path.read_text())
value = (
latest
if float(latest.get("expires_at", 0)) > time.time() + 60
else self.photos.oauth_tokens.refresh(source.kind, latest, path)
)
return value
except (ValueError, TypeError, AttributeError):
raise FlowError(