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:
2026-12-03 23:24:24 +00:00
parent 806b5eca46
commit fc7dbb0ac0
138 changed files with 1958 additions and 4651 deletions
@@ -27,7 +27,7 @@ bool _switchValue(WidgetTester tester) {
}
void main() {
testWidgets('shows the switch, status and ntfy note', (tester) async {
testWidgets('shows the switch, status and delivery note', (tester) async {
final service = FakeNotificationService();
await tester.pumpWidget(_host(service));
await tester.pumpAndSettle();
@@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/core/transport/connection_state.dart';
import 'package:pipelines_app/features/settings/settings_ntfy_section.dart';
import 'package:pipelines_app/features/settings/settings_notification_settings_section.dart';
/// A scripted gateway: records every request and answers from [respond].
class _Gateway implements ApiGateway {
@@ -32,24 +32,31 @@ JsonMap _reply(bool run, bool needs, bool reply) => {
},
};
Widget _host(ApiGateway gateway) {
Widget _host(ApiGateway gateway, {bool connected = true}) {
final body = SingleChildScrollView(
child: SettingsNtfySection(gateway: gateway, connected: true),
child: SettingsNotificationSettingsSection(
gateway: gateway,
connected: connected,
),
);
return MaterialApp(home: Scaffold(body: body));
}
bool _checked(WidgetTester tester, String key) {
final tile = find.byKey(ntfySettingKey(key));
return tester.widget<CheckboxListTile>(tile).value!;
}
Finder _tile(String key) => find.byKey(notificationSettingKey(key));
bool _checked(WidgetTester tester, String key) =>
tester.widget<CheckboxListTile>(_tile(key)).value!;
void main() {
testWidgets('loads the stored values', (tester) async {
testWidgets('shows the three shared switches with stored values', (
tester,
) async {
final gateway = _Gateway((_, _) => _reply(true, false, true));
await tester.pumpWidget(_host(gateway));
await tester.pumpAndSettle();
expect(gateway.calls.single.$1, 'notification_settings');
expect(find.text(notificationEventsTitle), findsOneWidget);
expect(find.text(notificationEventsSubtitle), findsOneWidget);
expect(find.text('Notify when any run ends'), findsOneWidget);
expect(
find.text('Otherwise only runs started with Notify me'),
@@ -57,14 +64,13 @@ void main() {
);
expect(find.text('Chat needs your answer or approval'), findsOneWidget);
expect(find.text('Chat reply finished'), findsOneWidget);
expect(find.text(ntfySectionSubtitle), findsOneWidget);
expect(find.byType(CheckboxListTile), findsNWidgets(3));
expect(_checked(tester, 'run_finished'), isTrue);
expect(_checked(tester, 'chat_needs_you'), isFalse);
expect(_checked(tester, 'chat_reply_finished'), isTrue);
});
testWidgets('shows the server default: only marked runs', (tester) async {
// The server's defaults: run ends notify only for "Notify me" runs.
final gateway = _Gateway((_, _) => _reply(false, true, false));
await tester.pumpWidget(_host(gateway));
await tester.pumpAndSettle();
@@ -73,24 +79,53 @@ void main() {
expect(_checked(tester, 'chat_reply_finished'), isFalse);
});
testWidgets('toggling writes only that setting', (tester) async {
final gateway = _Gateway((type, fields) {
if (type == 'set_notification_settings') {
return _reply(true, true, true);
}
return _reply(true, true, false);
for (final key in ['run_finished', 'chat_needs_you', 'chat_reply_finished']) {
testWidgets('toggling $key writes only that setting', (tester) async {
final gateway = _Gateway((type, fields) {
if (type == 'set_notification_settings') {
return _reply(true, true, true);
}
return _reply(false, false, false);
});
await tester.pumpWidget(_host(gateway));
await tester.pumpAndSettle();
await tester.tap(_tile(key));
await tester.pumpAndSettle();
expect(gateway.calls, hasLength(2));
expect(gateway.calls.last.$1, 'set_notification_settings');
expect(gateway.calls.last.$2, {
'notification_settings': {key: true},
});
expect(_checked(tester, key), isTrue);
expect(find.byKey(notificationSettingsErrorKey), findsNothing);
});
}
testWidgets('a legacy ntfy_enabled key in the reply is ignored', (
tester,
) async {
JsonMap legacy() => {
'type': 'notification_settings',
'notification_settings': {
...(_reply(true, true, false)['notification_settings'] as Map),
'ntfy_enabled': true,
},
};
final gateway = _Gateway((_, _) => legacy());
await tester.pumpWidget(_host(gateway));
await tester.pumpAndSettle();
await tester.tap(find.byKey(ntfySettingKey('chat_reply_finished')));
expect(find.byType(CheckboxListTile), findsNWidgets(3));
expect(_tile('ntfy_enabled'), findsNothing);
expect(find.textContaining('ntfy'), findsNothing);
expect(find.byKey(notificationSettingsErrorKey), findsNothing);
// A write after such a reply still sends only the toggled key.
await tester.tap(_tile('chat_reply_finished'));
await tester.pumpAndSettle();
expect(gateway.calls, hasLength(2));
expect(gateway.calls.last.$1, 'set_notification_settings');
expect(gateway.calls.last.$2, {
'notification_settings': {'chat_reply_finished': true},
});
expect(_checked(tester, 'chat_reply_finished'), isTrue);
expect(find.byKey(ntfyErrorKey), findsNothing);
expect(find.byType(CheckboxListTile), findsNWidgets(3));
});
testWidgets('failure reverts and shows the refusal', (tester) async {
@@ -101,53 +136,50 @@ void main() {
});
await tester.pumpWidget(_host(gateway));
await tester.pumpAndSettle();
await tester.tap(find.byKey(ntfySettingKey('run_finished')));
await tester.tap(_tile('run_finished'));
await tester.pump();
// The change shows at once and the group is disabled while it saves.
expect(_checked(tester, 'run_finished'), isFalse);
await tester.tap(find.byKey(ntfySettingKey('chat_needs_you')));
await tester.tap(_tile('chat_needs_you'));
await tester.pump();
expect(gateway.calls, hasLength(2));
pending.completeError(const ProtocolError('settings are read-only'));
await tester.pumpAndSettle();
expect(_checked(tester, 'run_finished'), isTrue);
expect(_checked(tester, 'chat_needs_you'), isTrue);
expect(
find.text('Could not save: settings are read-only'),
findsOneWidget,
);
expect(find.text('Could not save: settings are read-only'), findsOneWidget);
});
testWidgets('disabled while loading and offline', (tester) async {
testWidgets('disabled while loading', (tester) async {
final pending = Completer<JsonMap>();
final gateway = _Gateway((_, _) => pending.future);
await tester.pumpWidget(_host(gateway));
await tester.pump();
expect(find.text('Loading…'), findsOneWidget);
await tester.tap(find.byKey(ntfySettingKey('run_finished')));
await tester.tap(_tile('run_finished'));
await tester.pump();
expect(gateway.calls, hasLength(1));
expect(
tester
.widget<CheckboxListTile>(find.byKey(ntfySettingKey('run_finished')))
.onChanged,
tester.widget<CheckboxListTile>(_tile('run_finished')).onChanged,
isNull,
);
pending.complete(_reply(true, true, false));
await tester.pumpAndSettle();
expect(find.text('Loading…'), findsNothing);
});
final offline = _Gateway((_, _) => _reply(true, true, false));
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: SettingsNtfySection(gateway: offline, connected: false),
),
),
);
testWidgets('offline: no request, the offline text, switches disabled', (
tester,
) async {
final gateway = _Gateway((_, _) => _reply(true, true, false));
await tester.pumpWidget(_host(gateway, connected: false));
await tester.pumpAndSettle();
expect(offline.calls, isEmpty);
expect(find.text(ntfyOfflineText), findsOneWidget);
expect(gateway.calls, isEmpty);
expect(find.text(notificationEventsOfflineText), findsOneWidget);
expect(
tester.widget<CheckboxListTile>(_tile('chat_needs_you')).onChanged,
isNull,
);
});
testWidgets('a load failure is shown with a retry', (tester) async {
@@ -165,47 +197,7 @@ void main() {
fail = false;
await tester.tap(find.text('Retry'));
await tester.pumpAndSettle();
expect(find.byKey(ntfyErrorKey), findsNothing);
expect(
tester
.widget<CheckboxListTile>(find.byKey(ntfySettingKey('run_finished')))
.value,
isFalse,
);
});
group('ntfy_enabled', () {
JsonMap withNtfy(bool ntfy) => {
'type': 'notification_settings',
'notification_settings': {
...(_reply(true, true, false)['notification_settings'] as Map),
'ntfy_enabled': ntfy,
},
};
testWidgets('hidden when the server does not send it', (tester) async {
final gateway = _Gateway((_, _) => _reply(true, true, false));
await tester.pumpWidget(_host(gateway));
await tester.pumpAndSettle();
expect(find.byKey(ntfySettingKey('ntfy_enabled')), findsNothing);
expect(find.text(ntfySectionSubtitle), findsOneWidget);
});
testWidgets('shows and writes it', (tester) async {
final gateway = _Gateway(
(type, _) => withNtfy(type == 'set_notification_settings'),
);
await tester.pumpWidget(_host(gateway));
await tester.pumpAndSettle();
expect(find.text('Also send to ntfy'), findsOneWidget);
expect(find.text(ntfySectionAppSubtitle), findsOneWidget);
expect(_checked(tester, 'ntfy_enabled'), isFalse);
await tester.tap(find.byKey(ntfySettingKey('ntfy_enabled')));
await tester.pumpAndSettle();
expect(gateway.calls.last.$2, {
'notification_settings': {'ntfy_enabled': true},
});
expect(_checked(tester, 'ntfy_enabled'), isTrue);
});
expect(find.byKey(notificationSettingsErrorKey), findsNothing);
expect(_checked(tester, 'run_finished'), isFalse);
});
}
@@ -164,8 +164,8 @@ void main() {
'ping',
'notification_settings',
]);
await openSettingsSection(tester, 'Phone notifications');
_answerNtfySettings(factory.last);
await openSettingsSection(tester, 'Notification events');
_answerNotificationSettings(factory.last);
await tester.pump();
await tester.pump();
expect(factory.last.decodedOutgoing, hasLength(2));
@@ -203,8 +203,8 @@ void main() {
expect(find.text(serverDetailsPending), findsNothing);
expect(find.text('Server build unavailable'), findsOneWidget);
expect(find.text('Server time unavailable'), findsOneWidget);
await openSettingsSection(tester, 'Phone notifications');
_answerNtfySettings(factory.last);
await openSettingsSection(tester, 'Notification events');
_answerNotificationSettings(factory.last);
await tester.pump();
});
@@ -521,8 +521,8 @@ Future<void> _pump(
await openSettingsSection(tester, 'Connection');
}
/// Answers the Settings screen's queued ntfy-settings load on [channel].
void _answerNtfySettings(FakeChannel channel) {
/// Answers the Settings screen's queued notification-settings load on [channel].
void _answerNotificationSettings(FakeChannel channel) {
final request = channel.decodedOutgoing.last;
expect(request['type'], 'notification_settings');
channel.reply(<String, dynamic>{
@@ -48,7 +48,7 @@ void main() {
..._filler(6),
SettingsSection(
id: 'server',
title: 'Phone notifications',
title: 'Notification events',
lazy: true,
builder: (_) => ServerSettingsView<int>(
load: load,
@@ -60,11 +60,11 @@ void main() {
// The local sections are built and the server section is only a skeleton:
// no request runs until the list reaches it.
expect(find.text('filler body'), findsWidgets);
expect(find.text('Phone notifications'), findsOneWidget);
expect(find.text('Notification events'), findsOneWidget);
expect(fetches, 0);
expect(tester.takeException(), isNull);
await tester.ensureVisible(find.text('Phone notifications'));
await tester.ensureVisible(find.text('Notification events'));
await tester.pump();
await tester.pump();
expect(fetches, 1);
@@ -131,8 +131,8 @@ void main() {
..._filler(6),
SettingsSection(
id: 'server',
title: 'Phone notifications',
keywords: 'ntfy push',
title: 'Notification events',
keywords: 'push devices',
lazy: true,
builder: (_) => ServerSettingsView<int>(
load: load,
@@ -144,7 +144,7 @@ void main() {
await tester.enterText(
find.byKey(const ValueKey('settings.search')),
'ntfy',
'devices',
);
await tester.pump();
await tester.pump();