syncDevice method

Future<void> syncDevice(
  1. String deviceKey
)

Attempts a sync with the provided device key. Canceled if the device is not online.

Implementation

Future<void> syncDevice(String deviceKey) async {
  final device = await db.devices.id(deviceKey).get();
  if (device == null) {
    _logger.log('Missing device');
    return;
  }

  if (device.isRevoked) {
    _logger.log('Device $deviceKey is revoked');
    return;
  }

  if (!device.online) {
    _logger.log('Device is not reachable');
    return;
  }

  final deviceIp = device.ip;
  if (deviceIp == null) {
    _logger.log('Device $deviceKey has no IP');
    return;
  }

  await syncIP(deviceIp);
}