30 lines
771 B
Python
30 lines
771 B
Python
from __future__ import annotations
|
|
|
|
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def resolve_merged_config(cfg: dict, account_id: str) -> dict:
|
|
gc_config = cfg.get("channels", {}).get("googlechat", {}) if cfg else {}
|
|
|
|
defaults = gc_config.get("accounts", {}).get("default", {})
|
|
account_cfg = gc_config.get("accounts", {}).get(account_id, {})
|
|
|
|
merged = {**gc_config, **defaults, **account_cfg}
|
|
|
|
clear_base = {
|
|
"serviceAccount",
|
|
"serviceAccountFile",
|
|
"audienceType",
|
|
"audience",
|
|
"webhookPath",
|
|
"webhookUrl",
|
|
"botUser",
|
|
"name",
|
|
}
|
|
for field in clear_base:
|
|
if field not in account_cfg and field not in defaults:
|
|
merged.pop(field, None)
|
|
|
|
return merged |