Synapse падал в цикле: /opt/matrix/data принадлежал root вместо 991 и
контейнер пересоздался без сети matrix_matrix-net. Исправлено chown,
security-opt и подключением к сети; Matrix 200, боты работают.
Telegram-мост ожил после подключения к той же сети.
Добавлен POST/GET /notify в hub-core: шлёт сообщение в Matrix владельцу через
MEDIA-бота. Kuma получила webhook-уведомление с шаблоном
[{{STATUS}}] {{NAME}} и привязку ко всем мониторам. В HA добавлен
rest_command.hub_notify — проверено 200.
Написана карта связей между сервисами (ops/integration/LINKS.md): что связано,
что нет и какие решения ещё не задействованы (n8n, mautrix-мосты, Bazarr,
Vaultwarden, Zigbee2MQTT, Alertmanager, Paperless intake, Immich upload).
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
"""Добавляет /notify в do_POST."""
|
|
import ast
|
|
|
|
P = "/opt/hub-core/core.py"
|
|
s = open(P, encoding="utf-8").read()
|
|
|
|
if s.count('"/notify"') >= 2 or s.count("startswith(\"/notify\")") >= 2:
|
|
print("уже есть в обоих")
|
|
raise SystemExit(0)
|
|
|
|
route = ''' if self.path.startswith("/notify"):
|
|
try:
|
|
ln = int(self.headers.get("Content-Length") or 0)
|
|
raw = self.rfile.read(ln) if ln else b"{}"
|
|
data = json.loads(raw or b"{}")
|
|
except Exception:
|
|
data = {}
|
|
title = (data.get("title") or data.get("name") or "Событие").strip()
|
|
msg = (data.get("message") or data.get("msg") or "").strip()
|
|
ok = _matrix_notify("🔔 " + title + (("\\n" + msg) if msg else ""))
|
|
return self._json(200 if ok else 502, {"sent": bool(ok)})
|
|
|
|
'''
|
|
|
|
start = s.find(" def do_POST(self):")
|
|
if start < 0:
|
|
print("нет do_POST")
|
|
raise SystemExit(1)
|
|
anchor = ' if self.path.startswith("/event"):'
|
|
i = s.find(anchor, start)
|
|
if i < 0:
|
|
print("нет /event в do_POST")
|
|
raise SystemExit(1)
|
|
s = s[:i] + route + s[i:]
|
|
open(P, "w", encoding="utf-8").write(s)
|
|
ast.parse(s)
|
|
print("core.py: /notify добавлен в do_POST")
|