requestRosterPushes method

Future<Result<RosterRequestResult?, RosterError>> requestRosterPushes()

Requests a series of roster pushes according to RFC6121. Requires that the server advertises urn:xmpp:features:rosterver in the stream features.

Implementation

Future<Result<RosterRequestResult?, RosterError>>
    requestRosterPushes() async {
  final attrs = getAttributes();
  final rosterVersion = await _stateManager.getRosterVersion();
  final result = (await attrs.sendStanza(
    StanzaDetails(
      Stanza.iq(
        type: 'get',
        children: [
          XMLNode.xmlns(
            tag: 'query',
            xmlns: rosterXmlns,
            attributes: {
              'ver': rosterVersion ?? '',
            },
          ),
        ],
      ),
    ),
  ))!;

  if (result.attributes['type'] != 'result') {
    logger.warning('Requesting roster pushes failed: ${result.toXml()}');
    return Result(UnknownError());
  }

  final query = result.firstTag('query', xmlns: rosterXmlns);
  return _handleRosterResponse(query, rosterVersion);
}