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).
66 lines
2.8 KiB
Python
66 lines
2.8 KiB
Python
"""Правит /notify: в POST использовать готовый data, в GET — query."""
|
|
import ast
|
|
import re
|
|
|
|
P = "/opt/hub-core/core.py"
|
|
s = open(P, encoding="utf-8").read()
|
|
|
|
# 1) do_POST: заменяем блок, который читает body
|
|
old_post = ''' 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)})
|
|
'''
|
|
new_post = ''' if self.path.startswith("/notify"):
|
|
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)})
|
|
'''
|
|
|
|
if old_post in s:
|
|
s = s.replace(old_post, new_post, 1)
|
|
print(" do_POST исправлен")
|
|
else:
|
|
print(" блок do_POST не найден — проверю вручную")
|
|
|
|
# 2) do_GET: наш блок тоже читает body — переделаем на query
|
|
old_get = ''' 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()
|
|
text = "🔔 " + title + (("\\n" + msg) if msg else "")
|
|
ok = _matrix_notify(text)
|
|
return self._json(200 if ok else 502, {"sent": bool(ok)})
|
|
'''
|
|
new_get = ''' if self.path.startswith("/notify"):
|
|
from urllib.parse import parse_qs, urlparse as _up
|
|
qs = parse_qs(_up(self.path).query)
|
|
title = (qs.get("title") or qs.get("name") or ["Событие"])[0]
|
|
msg = (qs.get("message") or qs.get("msg") or [""])[0]
|
|
ok = _matrix_notify("🔔 " + title + (("\\n" + msg) if msg else ""))
|
|
return self._json(200 if ok else 502, {"sent": bool(ok)})
|
|
'''
|
|
|
|
if old_get in s:
|
|
s = s.replace(old_get, new_get, 1)
|
|
print(" do_GET исправлен")
|
|
else:
|
|
print(" блок do_GET не найден")
|
|
|
|
open(P, "w", encoding="utf-8").write(s)
|
|
ast.parse(s)
|
|
print("core.py обновлён")
|