Browse Source

chore(neon,neon_notifications,app): Adjust

Signed-off-by: jld3103 <jld3103yt@gmail.com>
pull/710/head
jld3103 1 year ago
parent
commit
0f43e2baf2
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 2
      packages/app/integration_test/screenshot_test.dart
  2. 4
      packages/neon/neon/lib/src/blocs/push_notifications.dart
  3. 4
      packages/neon/neon/lib/src/utils/push_utils.dart
  4. 13
      packages/neon/neon_notifications/lib/blocs/notifications.dart

2
packages/app/integration_test/screenshot_test.dart

@ -279,7 +279,7 @@ Future main() async {
}); });
testWidgets('notifications', (final tester) async { testWidgets('notifications', (final tester) async {
await (await getAccount('admin')).client.notifications.sendAdminNotification( await (await getAccount('admin')).client.notifications.api.generateNotification(
userId: account.username, userId: account.username,
shortMessage: 'Notifications demo', shortMessage: 'Notifications demo',
longMessage: 'This is a notifications demo of the Neon app', longMessage: 'This is a notifications demo of the Neon app',

4
packages/neon/neon/lib/src/blocs/push_notifications.dart

@ -85,7 +85,7 @@ class PushNotificationsBloc extends Bloc implements PushNotificationsBlocEvents,
debugPrint('Registering account $instance for push notifications on $endpoint'); 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), pushTokenHash: generatePushTokenHash(endpoint),
devicePublicKey: keypair.publicKey.toFormattedPEM(), devicePublicKey: keypair.publicKey.toFormattedPEM(),
proxyServer: '$endpoint#', // This is a hack to make the Nextcloud server directly push to the endpoint proxyServer: '$endpoint#', // This is a hack to make the Nextcloud server directly push to the endpoint
@ -121,7 +121,7 @@ class PushNotificationsBloc extends Bloc implements PushNotificationsBlocEvents,
Future _unregisterUnifiedPushInstances(final List<Account> accounts) async { Future _unregisterUnifiedPushInstances(final List<Account> accounts) async {
for (final account in accounts) { for (final account in accounts) {
try { try {
await account.client.notifications.removeDevice(); await account.client.notifications.push.removeDevice();
await UnifiedPush.unregister(account.id); await UnifiedPush.unregister(account.id);
await _storage.remove(_keyLastEndpoint(account)); await _storage.remove(_keyLastEndpoint(account));
} catch (e) { } catch (e) {

4
packages/neon/neon/lib/src/utils/push_utils.dart

@ -103,7 +103,9 @@ class PushUtils {
account = accounts.tryFind(instance); account = accounts.tryFind(instance);
if (account != null) { if (account != null) {
notification = 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) { if (notification.icon?.endsWith('.svg') ?? false) {
// Only SVG icons are supported right now (should be most of them) // Only SVG icons are supported right now (should be most of them)

13
packages/neon/neon_notifications/lib/blocs/notifications.dart

@ -50,22 +50,25 @@ class NotificationsBloc extends InteractiveBloc
@override @override
Future refresh() async { Future refresh() async {
await RequestManager.instance.wrapNextcloud<List<NotificationsNotification>, NotificationsListNotifications>( await RequestManager.instance.wrapNextcloud<
List<NotificationsNotification>,
NotificationsResponse<NotificationsEndpointListNotificationsResponseApplicationJson,
NotificationsEndpointEndpointListNotificationsHeaders>>(
_account.id, _account.id,
'notifications-notifications', 'notifications-notifications',
notifications, notifications,
() async => _account.client.notifications.listNotifications(), () async => _account.client.notifications.endpoint.listNotifications(),
(final response) => response.ocs.data.toList(), (final response) => response.data.ocs.data.toList(),
); );
} }
@override @override
void deleteAllNotifications() { void deleteAllNotifications() {
wrapAction(() async => _account.client.notifications.deleteAllNotifications()); wrapAction(() async => _account.client.notifications.endpoint.deleteAllNotifications());
} }
@override @override
void deleteNotification(final int id) { void deleteNotification(final int id) {
wrapAction(() async => _account.client.notifications.deleteNotification(id: id)); wrapAction(() async => _account.client.notifications.endpoint.deleteNotification(id: id));
} }
} }

Loading…
Cancel
Save