delete method

Future<Result<PubSubError, bool>> delete(
  1. JID host,
  2. String node
)

Implementation

Future<Result<PubSubError, bool>> delete(JID host, String node) async {
  final request = (await getAttributes().sendStanza(
    StanzaDetails(
      Stanza.iq(
        type: 'set',
        to: host.toString(),
        children: [
          XMLNode.xmlns(
            tag: 'pubsub',
            xmlns: pubsubOwnerXmlns,
            children: [
              XMLNode(
                tag: 'delete',
                attributes: <String, String>{
                  'node': node,
                },
              ),
            ],
          ),
        ],
      ),
      shouldEncrypt: false,
    ),
  ))!;

  if (request.attributes['type'] != 'result') {
    // TODO(Unknown): Be more specific
    return Result(UnknownPubSubError());
  }

  return const Result(true);
}