Skip to content

Commit

Permalink
Merge pull request #1964 from atsign-foundation/fix_notify_text
Browse files Browse the repository at this point in the history
fix: Invalid AtKey causes exception in notify list during authorizati…
  • Loading branch information
gkc authored May 22, 2024
2 parents 2ca7d9e + e509c66 commit b4aae86
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import 'dart:collection';
import 'dart:convert';

import 'package:at_commons/at_commons.dart';
import 'package:at_persistence_secondary_server/at_persistence_secondary_server.dart';
import 'package:at_secondary/src/connection/inbound/inbound_connection_metadata.dart';
import 'package:at_secondary/src/constants/enroll_constants.dart';
import 'package:at_secondary/src/enroll/enroll_datastore_value.dart';
import 'package:at_secondary/src/server/at_secondary_impl.dart';
import 'package:at_secondary/src/utils/handler_util.dart' as handler_util;
import 'package:at_secondary/src/utils/secondary_util.dart';
import 'package:at_secondary/src/verb/handler/sync_progressive_verb_handler.dart';
import 'package:at_secondary/src/verb/manager/response_handler_manager.dart';
import 'package:at_server_spec/at_server_spec.dart';
import 'package:at_server_spec/at_verb_spec.dart';
import 'package:at_utils/at_logger.dart';
import 'package:at_secondary/src/utils/secondary_util.dart';

final String paramFullCommandAsReceived = 'FullCommandAsReceived';

Expand Down Expand Up @@ -190,8 +191,13 @@ abstract class AbstractVerbHandler implements VerbHandler {
}
}
// set passed namespace. If passed namespace is null, get namespace from atKey
final keyNamespace =
namespace ?? (atKey != null ? AtKey.fromString(atKey).namespace : null);
String? keyNamespace;
try {
keyNamespace = namespace ??
(atKey != null ? AtKey.fromString(atKey).namespace : null);
} catch (e) {
throw AtEnrollmentException('AtKey.toString($atKey) failed: $e');
}
if (keyNamespace == null && atKey == null) {
logger.shout('Both AtKey and namespace are null');
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,14 @@ class NotifyListVerbHandler extends AbstractVerbHandler {
var filteredResponseList = [];
for (Notification notification in responseList) {
var notificationKey = notification.notification;
if (await super
.isAuthorized(atConnectionMetadata, atKey: notificationKey!)) {
filteredResponseList.add(notification);
try {
if (await super
.isAuthorized(atConnectionMetadata, atKey: notificationKey!)) {
filteredResponseList.add(notification);
}
} on AtEnrollmentException catch (e) {
logger.finer(
'Failed to authorize the key with enrollment ID ${atConnectionMetadata.enrollmentId} caused by ${e.toString()}');
}
}
responseList.clear();
Expand Down

0 comments on commit b4aae86

Please sign in to comment.