isSupported method

  1. @override
Future<bool> isSupported()
override

Returns true if the XEP is supported on the server. If not, returns false

Implementation

@override
Future<bool> isSupported() async {
  if (_gotSupported) return _supported;

  final result = await getAttributes()
      .getManagerById<DiscoManager>(discoManager)!
      .performDiscoSweep();
  if (result.isType<DiscoError>()) {
    _gotSupported = false;
    _supported = false;
    return false;
  }

  final infos = result.get<List<DiscoInfo>>();
  _gotSupported = true;
  for (final info in infos) {
    if (_containsFileUploadIdentity(info) &&
        info.features.contains(httpFileUploadXmlns)) {
      logger.info('Discovered HTTP File Upload for ${info.jid}');

      _entityJid = info.jid;
      _maxUploadSize = _getMaxFileSize(info);
      _supported = true;
      break;
    }
  }

  return _supported;
}