Skip to content

Commit

Permalink
Merge pull request #710 from nextcloud/feature/notifications-generate…
Browse files Browse the repository at this point in the history
…d-spec

Feature/notifications generated spec
  • Loading branch information
provokateurin authored Sep 7, 2023
2 parents b926887 + 0f43e2b commit 8924417
Show file tree
Hide file tree
Showing 13 changed files with 6,553 additions and 2,151 deletions.
2 changes: 1 addition & 1 deletion external/nextcloud-notifications
Submodule nextcloud-notifications updated 95 files
+3 −3 .github/dependabot.yml
+13 −2 .github/workflows/block-merge-freeze.yml
+19 −13 .github/workflows/command-compile.yml
+4 −4 .github/workflows/command-rebase.yml
+1 −1 .github/workflows/lint-eslint-when-unrelated.yml
+6 −6 .github/workflows/lint-eslint.yml
+5 −6 .github/workflows/lint-info-xml.yml
+4 −3 .github/workflows/lint-php-cs.yml
+4 −3 .github/workflows/lint-php.yml
+6 −6 .github/workflows/lint-stylelint.yml
+5 −5 .github/workflows/node.yml
+38 −0 .github/workflows/openapi.yml
+7 −6 .github/workflows/performance.yml
+14 −12 .github/workflows/phpunit-mysql.yml
+25 −8 .github/workflows/phpunit-oci.yml
+9 −7 .github/workflows/phpunit-pgsql.yml
+8 −6 .github/workflows/phpunit-sqlite.yml
+1 −1 .github/workflows/phpunit-summary-when-unrelated.yml
+34 −0 .github/workflows/pr-feedback.yml
+3 −2 .github/workflows/psalm.yml
+56 −8 .github/workflows/update-nextcloud-ocp.yml
+1 −0 .gitignore
+2 −4 appinfo/info.xml
+10 −10 appinfo/routes.php
+18 −6 composer.json
+441 −1,350 composer.lock
+2 −2 js/notifications-admin-settings.js
+9 −0 js/notifications-admin-settings.js.LICENSE.txt
+1 −1 js/notifications-admin-settings.js.map
+2 −2 js/notifications-main.js
+1 −1 js/notifications-main.js.map
+2 −2 js/notifications-node_modules_moment_locale_sync_recursive_-src_NotificationsApp_vue.js
+1 −1 js/notifications-node_modules_moment_locale_sync_recursive_-src_NotificationsApp_vue.js.map
+2 −2 js/notifications-settings.js
+9 −0 js/notifications-settings.js.LICENSE.txt
+1 −1 js/notifications-settings.js.map
+0 −3 ...ons-vendors-node_modules_nextcloud_initial-state_dist_index_esm_js-node_modules_nextcloud_moment_-4efa53.js
+0 −1 ...vendors-node_modules_nextcloud_initial-state_dist_index_esm_js-node_modules_nextcloud_moment_-4efa53.js.map
+3 −0 ...ons-vendors-node_modules_nextcloud_moment_dist_index_js-node_modules_nextcloud_notify_push_dist_i-30bc25.js
+11 −2 ...node_modules_nextcloud_moment_dist_index_js-node_modules_nextcloud_notify_push_dist_i-30bc25.js.LICENSE.txt
+1 −0 ...vendors-node_modules_nextcloud_moment_dist_index_js-node_modules_nextcloud_notify_push_dist_i-30bc25.js.map
+23 −2 l10n/ar.js
+23 −2 l10n/ar.json
+2 −0 l10n/az.js
+2 −0 l10n/az.json
+2 −0 l10n/da.js
+2 −0 l10n/da.json
+1 −1 l10n/de.js
+1 −1 l10n/de.json
+4 −0 l10n/el.js
+4 −0 l10n/el.json
+19 −0 l10n/es_EC.js
+19 −0 l10n/es_EC.json
+1 −0 l10n/et_EE.js
+1 −0 l10n/et_EE.json
+16 −0 l10n/fa.js
+16 −0 l10n/fa.json
+12 −12 l10n/gl.js
+12 −12 l10n/gl.json
+9 −0 l10n/hi_IN.js
+7 −0 l10n/hi_IN.json
+3 −3 l10n/ko.js
+3 −3 l10n/ko.json
+4 −1 l10n/lo.js
+4 −1 l10n/lo.json
+12 −0 l10n/mk.js
+12 −0 l10n/mk.json
+1 −1 l10n/sl.js
+1 −1 l10n/sl.json
+1 −0 l10n/th.js
+1 −0 l10n/th.json
+4 −4 l10n/zh_CN.js
+4 −4 l10n/zh_CN.json
+1 −1 l10n/zh_HK.js
+1 −1 l10n/zh_HK.json
+8 −1 lib/Capabilities.php
+15 −7 lib/Controller/APIController.php
+45 −14 lib/Controller/EndpointController.php
+23 −5 lib/Controller/PushController.php
+15 −0 lib/Controller/SettingsController.php
+9 −1 lib/Listener/UserDeletedListener.php
+13 −0 lib/Model/SettingsMapper.php
+63 −0 lib/ResponseDefinitions.php
+1,546 −0 openapi.json
+29,316 −23,022 package-lock.json
+49 −49 package.json
+12 −5 psalm.xml
+10 −12 src/Components/Notification.vue
+3 −3 src/NotificationsApp.vue
+1 −1 tests/Integration/app/appinfo/info.xml
+53 −55 tests/Integration/composer.lock
+2 −2 tests/Integration/features/bootstrap/FeatureContext.php
+11 −21 tests/psalm-baseline.xml
+16 −0 vendor-bin/openapi-extractor/composer.json
+235 −0 vendor-bin/openapi-extractor/composer.lock
2 changes: 1 addition & 1 deletion packages/app/integration_test/screenshot_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ Future main() async {
});

testWidgets('notifications', (final tester) async {
await (await getAccount('admin')).client.notifications.sendAdminNotification(
await (await getAccount('admin')).client.notifications.api.generateNotification(
userId: account.username,
shortMessage: 'Notifications demo',
longMessage: 'This is a notifications demo of the Neon app',
Expand Down
4 changes: 2 additions & 2 deletions packages/neon/neon/lib/src/blocs/push_notifications.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class PushNotificationsBloc extends Bloc implements PushNotificationsBlocEvents,

debugPrint('Registering account $instance for push notifications on $endpoint');

final subscription = await account.client.notifications.registerDevice(
final subscription = await account.client.notifications.push.registerDevice(
pushTokenHash: generatePushTokenHash(endpoint),
devicePublicKey: keypair.publicKey.toFormattedPEM(),
proxyServer: '$endpoint#', // This is a hack to make the Nextcloud server directly push to the endpoint
Expand Down Expand Up @@ -121,7 +121,7 @@ class PushNotificationsBloc extends Bloc implements PushNotificationsBlocEvents,
Future _unregisterUnifiedPushInstances(final List<Account> accounts) async {
for (final account in accounts) {
try {
await account.client.notifications.removeDevice();
await account.client.notifications.push.removeDevice();
await UnifiedPush.unregister(account.id);
await _storage.remove(_keyLastEndpoint(account));
} catch (e) {
Expand Down
4 changes: 3 additions & 1 deletion packages/neon/neon/lib/src/utils/push_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ class PushUtils {
account = accounts.tryFind(instance);
if (account != null) {
notification =
(await account.client.notifications.getNotification(id: pushNotification.subject.nid!)).ocs.data;
(await account.client.notifications.endpoint.getNotification(id: pushNotification.subject.nid!))
.ocs
.data;
if (notification.icon?.endsWith('.svg') ?? false) {
// Only SVG icons are supported right now (should be most of them)

Expand Down
13 changes: 8 additions & 5 deletions packages/neon/neon_notifications/lib/blocs/notifications.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,25 @@ class NotificationsBloc extends InteractiveBloc

@override
Future refresh() async {
await RequestManager.instance.wrapNextcloud<List<NotificationsNotification>, NotificationsListNotifications>(
await RequestManager.instance.wrapNextcloud<
List<NotificationsNotification>,
NotificationsResponse<NotificationsEndpointListNotificationsResponseApplicationJson,
NotificationsEndpointEndpointListNotificationsHeaders>>(
_account.id,
'notifications-notifications',
notifications,
() async => _account.client.notifications.listNotifications(),
(final response) => response.ocs.data.toList(),
() async => _account.client.notifications.endpoint.listNotifications(),
(final response) => response.data.ocs.data.toList(),
);
}

@override
void deleteAllNotifications() {
wrapAction(() async => _account.client.notifications.deleteAllNotifications());
wrapAction(() async => _account.client.notifications.endpoint.deleteAllNotifications());
}

@override
void deleteNotification(final int id) {
wrapAction(() async => _account.client.notifications.deleteNotification(id: id));
wrapAction(() async => _account.client.notifications.endpoint.deleteNotification(id: id));
}
}
6 changes: 3 additions & 3 deletions packages/nextcloud/lib/src/api/core.openapi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4664,10 +4664,10 @@ abstract class CoreNotesCapabilities
@BuiltValue(instantiable: false)
abstract interface class CoreNotificationsCapabilities_NotificationsInterface {
@BuiltValueField(wireName: 'ocs-endpoints')
BuiltList<String>? get ocsEndpoints;
BuiltList<String>? get push;
BuiltList<String> get ocsEndpoints;
BuiltList<String> get push;
@BuiltValueField(wireName: 'admin-notifications')
BuiltList<String>? get adminNotifications;
BuiltList<String> get adminNotifications;
CoreNotificationsCapabilities_NotificationsInterface rebuild(
final void Function(CoreNotificationsCapabilities_NotificationsInterfaceBuilder) updates,
);
Expand Down
60 changes: 27 additions & 33 deletions packages/nextcloud/lib/src/api/core.openapi.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion packages/nextcloud/lib/src/api/core.openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,11 @@
"properties": {
"notifications": {
"type": "object",
"additionalProperties": true,
"required": [
"ocs-endpoints",
"push",
"admin-notifications"
],
"properties": {
"ocs-endpoints": {
"type": "array",
Expand Down
Loading

0 comments on commit 8924417

Please sign in to comment.