doOnNewEndpoint method

Future<DBusMethodResponse> doOnNewEndpoint(
  1. String instance,
  2. Map<String, DBusValue> args
)

Implementation of org.unifiedpush.Connector2.NewEndpoint()

Implementation

Future<DBusMethodResponse> doOnNewEndpoint(
    String instance,
    Map<String, DBusValue> args
    ) async {
  final onNewEndpoint = _onNewEndpoint;
  if (onNewEndpoint == null) return _dbusSuccess;
  var serializedKey = await storage.keys.get(instance);
  WebPushKeySet key;
  if (serializedKey == null) {
    key = await WebPushKeySet.newKeyPair();
    storage.keys.set(instance, key.serialize);
  } else {
    key = await WebPushKeySet.deserialize(serializedKey);
  }
  onNewEndpoint.call(
    PushEndpoint(
      args["endpoint"]!.asString(),
      _publicKeySet(key.publicKey),
    ),
    instance
  );
  return  _dbusSuccess;
}