enableCarbons method

Future<bool> enableCarbons()

Send a request to the server, asking it to enable Message Carbons.

Returns true if carbons were enabled. False, if not.

Implementation

Future<bool> enableCarbons() async {
  final attrs = getAttributes();
  final result = (await attrs.sendStanza(
    StanzaDetails(
      Stanza.iq(
        to: attrs.getFullJID().toBare().toString(),
        type: 'set',
        children: [
          XMLNode.xmlns(
            tag: 'enable',
            xmlns: carbonsXmlns,
          ),
        ],
      ),
    ),
  ))!;

  if (result.attributes['type'] != 'result') {
    logger.warning('Failed to enable message carbons');

    return false;
  }

  logger.fine('Successfully enabled message carbons');

  _isEnabled = true;
  return true;
}