atsign-foundation / at_client_sdk

The Dart implementation of atSDK used for implementing Atsign's technology into other software
https://pub.dev/publishers/atsign.org/packages
BSD 3-Clause "New" or "Revised" License
1.46k stars 31 forks source link

.getKeys() does not provide a list with sharedWith parameter. #440

Closed CurtlyCritchlow closed 2 years ago

CurtlyCritchlow commented 2 years ago

Describe the bug The .getKeys() does not provide a list with sharedWith parameter.

To Reproduce Steps to reproduce the behavior:

  1. First I sent a key using the .put() method.

    var key = AtKey()
      ..key = 'dude'
      ..sharedBy = currentAtsign
      ..sharedWith = '@wildgreen'
      ..metadata = metaData;
    
    await atClient.put(
      key,
      'duude',
    );
  2. Then I retrieve a key using the .get(key) successfully

    var key = AtKey()
      ..key = 'dude'
      ..sharedBy = null
      ..sharedWith = '@wildgreen'
      ..metadata = metaData;
    
    var data = await atClient.get(key);

    the result is 'duude'

  3. And then I tried to retrieve a list of keys using the .getKeys() method but was unsuccessful.
    listData = await atClient.getKeys(
      regex: 'at_skeleton_app',
      sharedWith: '@wildgreen'
    );

The result is an empty list

Expected behavior List of key that was shared with "@wildgreen".

Screenshots Result when a sharedWith parameter is provided

getKeys with sharedWith parameter

Result when a sharedWith parameter is not provided

getKeys without shareWith parameter

Smartphone (please complete the following information):

Were you using an @‎application when the bug was found? No. I'm creating a new @application called at_dude

Additional context

gkc commented 2 years ago

@CurtlyCritchlow was this fixed or not a bug or ... ?

CurtlyCritchlow commented 2 years ago

It's not a bug. @cconstab explained that isPublic must be false in the metadata or the shareWith atSign will not be associated with the key. Maybe this should be mentioned in the documentation.

gkc commented 2 years ago

Ah yes. There's been a fair bit of work over the past couple of months around this part of the SDK as there are a few pitfalls like this (there still are, so we could keep backwards compatibility for now).

Most relevant would be https://github.com/atsign-foundation/at_tools/pull/133 which made various AtKey builders available.