Add remote browser pages and website sync
Enable managed remote browser custom pages with login autofill and add website sync workflows so external admin surfaces can be handled inside SmartUp. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,7 @@ from app.models.notification_log import NotificationLog
|
||||
from app.utils.dingtalk import (
|
||||
dingtalk_signed_url,
|
||||
format_dingtalk_rate_changed,
|
||||
format_dingtalk_website_rate_changed,
|
||||
format_dingtalk_status,
|
||||
)
|
||||
|
||||
@@ -101,6 +102,54 @@ def send_rate_changed(
|
||||
_log(db, wh, "upstream_rate_changed", generic_payload, "failed", str(exc))
|
||||
|
||||
|
||||
def send_website_rate_changed(
|
||||
db: Session,
|
||||
website_id: int,
|
||||
website_name: str,
|
||||
base_url: str,
|
||||
binding_id: int,
|
||||
target_group_id: str,
|
||||
target_group_name: str,
|
||||
old_rate: Any,
|
||||
new_rate: Any,
|
||||
source_rates: list[dict[str, Any]],
|
||||
) -> None:
|
||||
webhooks = (
|
||||
db.query(WebhookConfig)
|
||||
.filter(WebhookConfig.enabled == True)
|
||||
.all()
|
||||
)
|
||||
changed_at = _now_iso()
|
||||
generic_payload = {
|
||||
"event": "website_rate_changed",
|
||||
"website": {"id": website_id, "name": website_name, "base_url": base_url},
|
||||
"binding": {"id": binding_id},
|
||||
"target_group": {
|
||||
"id": target_group_id,
|
||||
"name": target_group_name,
|
||||
"old_rate": old_rate,
|
||||
"new_rate": new_rate,
|
||||
},
|
||||
"source_rates": source_rates,
|
||||
"changed_at": changed_at,
|
||||
}
|
||||
for wh in webhooks:
|
||||
events = json.loads(wh.events_json or "[]")
|
||||
if "website_rate_changed" not in events:
|
||||
continue
|
||||
try:
|
||||
if wh.type == "dingtalk":
|
||||
msg = format_dingtalk_website_rate_changed(
|
||||
website_name, target_group_name, changed_at, old_rate, new_rate
|
||||
)
|
||||
resp_text = _send_dingtalk(wh.url, wh.secret, msg)
|
||||
else:
|
||||
resp_text = _send_generic(wh.url, generic_payload)
|
||||
_log(db, wh, "website_rate_changed", generic_payload, "success", resp_text)
|
||||
except Exception as exc:
|
||||
_log(db, wh, "website_rate_changed", generic_payload, "failed", str(exc))
|
||||
|
||||
|
||||
def send_status_event(
|
||||
db: Session,
|
||||
upstream_id: int,
|
||||
|
||||
Reference in New Issue
Block a user