Skip to content

PostgreSQL backup tool with Point-In-Time-Recovery and restore verification

4.9 KB
Raw Blame

1. Backend

  • 1.1 Create the migration stub with goose -dir backend/migrations create add_telegram_bot_api_url sql and fill it to add a nullable bot_api_url TEXT column to telegram_notifiers in Up and drop it in Down, matching 20260622120000_add_telegram_proxy.sql. Add BotAPIURL string (json:"botApiUrl", column bot_api_url) to TelegramNotifier and copy it unconditionally in Update, leaving HideSensitiveData and EncryptSensitiveData untouched. Add a controller test that saves a Telegram notifier with a Bot API URL, reads it back with botApiUrl in clear and the bot token and proxy URL empty, then updates it with an empty URL and reads it back empty; verify with just test-package ./internal/features/notifiers/... in backend/
  • 1.2 Add validateBotAPIURL in backend/internal/features/notifiers/models/telegram/bot_api_url.go that accepts http/https with a host and rejects user info, a query and a fragment, and call it from Validate when the field is set. Add table tests on Validate in model_test.go beside the proxy tests for every valid and rejected URL in the spec, and a controller test that saving an invalid or credential-bearing URL is rejected and leaves the stored notifier unchanged; verify with just test-package ./internal/features/notifiers/... in backend/
  • 1.3 Make Send build the address from the validated Bot API URL with the trailing slash trimmed, or from https://api.telegram.org when the field is empty. Add a unit test in model_test.go that an empty Bot API URL yields https://api.telegram.org/bot<token>/sendMessage, and controller tests with httptest servers: a saved notifier with a prefixed, slash-terminated URL sent through POST /notifiers/:id/test delivers /<prefix>/bot<token>/sendMessage with its chat_id; an unsaved notifier sent through POST /notifiers/direct-test reaches the server the same way; a direct test with an invalid URL and with a URL holding user info returns an error while the server records no request; a notifier with a Bot API URL and a proxy pointing at an httptest proxy makes the proxy receive the request for the Bot API URL; a prefixed URL pointing at a closed server yields an error that names the host and not the token; verify with just test-package ./internal/features/notifiers/... in backend/
  • 1.4 Add RedactSecretInText(text, secret string) string to backend/internal/features/notifiers/models/url_credentials.go, replacing every occurrence of the secret with the existing redactedURLSegment marker, with a unit test in url_credentials_test.go, and apply it to the non-OK response body in the Telegram Send. Add a controller test where the Bot API server answers 404 with a body echoing the request path and the test-send error keeps the body with redacted in place of the token; verify with just test-package ./internal/features/notifiers/... in backend/

2. Frontend

  • 2.1 Add botApiUrl?: string to TelegramNotifier.ts, mirror the backend rules in validateTelegramNotifier.ts, and add the valid and rejected spec URLs to validateTelegramNotifier.test.ts; verify with pnpm test and pnpm typecheck in frontend/
  • 2.2 Move AdvancedSettingsToggleComponent from features/databases/ui/edit/ to shared/ui/ with the label as a prop, move AdvancedFieldRowComponent from EditEmailNotifierComponent.tsx to shared/ui/, export both from shared/ui/index.ts, switch the five database forms and the email form to them, delete the email form's inline header, and rename notifiers.email.advancedSettings to notifiers.advancedSettings in all six dictionaries; verify with pnpm lint, pnpm typecheck and pnpm test in frontend/
  • 2.3 Add the Bot API URL label, placeholder and tooltip (official API when empty, the URL receives the bot token, a bot must be moved to a self-hosted server first) to all six dictionaries, written in each language per the translation rules; verify with pnpm test (the dictionary placeholder test) and pnpm typecheck in frontend/
  • 2.4 Add the collapsible advanced settings section to EditTelegramNotifierComponent.tsx, holding the new Bot API URL field and the existing proxy switch and proxy URL, starting open when botApiUrl is set or isProxyEnabled is true. Add EditTelegramNotifierComponent.test.tsx rendering with renderToStaticMarkup: a new notifier renders without the proxy and Bot API URL labels, a notifier with a proxy and one with a Bot API URL render with them; verify with pnpm test in frontend/
  • 2.5 Show the Bot API URL in ShowTelegramNotifierComponent.tsx when it is set, with ShowTelegramNotifierComponent.test.tsx checking that the URL is rendered when set and absent otherwise; verify with pnpm test in frontend/

3. Final checks

  • 3.1 Run just format and just lint at the repository root and pnpm build in frontend/, and fix every finding in the touched files; verify all three exit cleanly