Remove ntfy: notifications go only through the app notification stream
Server: drop ntfy publishing (stage hooks, run outbox, chat attention, chat tool notify, auto-switch and schedule notices), the chat push outbox (its table is dropped at startup), ntfy status/endpoints and PIPELINES_NTFY_*. The app_notifications stream, subscribe/clear and kinds are unchanged. Notification settings keep run_finished/chat_needs_you/chat_reply_finished; ntfy_enabled is accepted and ignored and its stored row is never read. Stage type=ntfy is rejected: "ntfy stages were removed; notifications go to the Pipelines apps — use the stage notify hook". The notify hook remains. Installer: no ntfy build, accounts, config or supervisor child; manifest gets top-level "mode" (legacy ntfy.mode still read). Reinstall retires an old ntfy (safe PID-file stop, deletes binary, config, data dir, token, log, with a note in logs/install.log); uninstall cleans leftovers. App: ntfy settings section replaced by "Notification events"; texts updated. Docs: docs/ntfy.md folded into docs/notifications.md; install, docker, cli, author skill references updated; security review M1 marked resolved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,6 @@ import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
from urllib.parse import urlparse
|
||||
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
|
||||
|
||||
|
||||
@@ -74,49 +73,31 @@ def configure_client(endpoint, environ=None):
|
||||
return path
|
||||
|
||||
|
||||
def configure(directory, ntfy_url, bind_address, timezone=None, port=8081):
|
||||
def configure(directory, timezone=None, port=8081):
|
||||
directory = Path(directory)
|
||||
url = urlparse(ntfy_url)
|
||||
if (url.scheme not in ("http", "https") or not url.hostname or url.username
|
||||
or url.password or url.query or url.fragment or url.path not in ("", "/")):
|
||||
raise ValueError("--ntfy-url must be an HTTP(S) base URL without credentials or a topic")
|
||||
timezone = timezone or host_timezone()
|
||||
ZoneInfo(timezone)
|
||||
for value in (ntfy_url, bind_address, timezone):
|
||||
if any(char in value for char in "\r\n\x00$#'\" "):
|
||||
raise ValueError("Unsafe configuration value")
|
||||
if any(char in timezone for char in "\r\n\x00$#'\" "):
|
||||
raise ValueError("Unsafe configuration value")
|
||||
if not 1 <= port <= 65535:
|
||||
raise ValueError("Invalid pipeline port")
|
||||
settings = directory / ".env"
|
||||
if settings.exists():
|
||||
raise ValueError(".env exists; edit it rather than overwrite existing settings")
|
||||
workspace_values = host_workspaces(directory)
|
||||
secrets = directory / "secrets"
|
||||
secrets.mkdir(mode=0o700, exist_ok=True)
|
||||
token = secrets / "ntfy-token.txt"
|
||||
# Empty until ntfy has issued a token. Never replace an existing credential.
|
||||
try:
|
||||
fd = os.open(token, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600)
|
||||
os.close(fd)
|
||||
except FileExistsError:
|
||||
pass
|
||||
with settings.open("x") as file:
|
||||
file.write(f"TZ={timezone}\nNTFY_BASE_URL={ntfy_url.rstrip('/')}\n"
|
||||
f"NTFY_BIND_ADDRESS={bind_address}\nPIPELINES_PORT={port}\n")
|
||||
file.write(f"TZ={timezone}\nPIPELINES_PORT={port}\n")
|
||||
for key, value in workspace_values.items(): file.write(key+"="+value+"\n")
|
||||
return timezone
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--ntfy-url", required=True)
|
||||
parser.add_argument("--bind-address", default="0.0.0.0")
|
||||
parser.add_argument("--timezone")
|
||||
parser.add_argument("--port", type=int, default=8081)
|
||||
args = parser.parse_args()
|
||||
try:
|
||||
zone = configure(Path(__file__).resolve().parents[1], args.ntfy_url,
|
||||
args.bind_address, args.timezone, args.port)
|
||||
zone = configure(Path(__file__).resolve().parents[1], args.timezone, args.port)
|
||||
except (ValueError, ZoneInfoNotFoundError) as error:
|
||||
parser.error(str(error))
|
||||
print(f"Created .env with timezone {zone}. Configure the ntfy token before starting pipelines.")
|
||||
print(f"Created .env with timezone {zone}.")
|
||||
|
||||
Reference in New Issue
Block a user