removeFromRoster method
- String jid
Attempts to remove jid
from the roster. Returns true if the process was successful,
false otherwise.
Implementation
Future<RosterRemovalResult> removeFromRoster(String jid) async {
final attrs = getAttributes();
final response = (await attrs.sendStanza(
StanzaDetails(
Stanza.iq(
type: 'set',
children: [
XMLNode.xmlns(
tag: 'query',
xmlns: rosterXmlns,
children: [
XMLNode(
tag: 'item',
attributes: {
'jid': jid,
'subscription': 'remove',
},
),
],
),
],
),
),
))!;
if (response.attributes['type'] != 'result') {
logger.severe('Failed to remove roster item: ${response.toXml()}');
final error = response.firstTag('error')!;
final notFound = error.firstTag('item-not-found') != null;
if (notFound) {
logger.warning('Item was not found');
return RosterRemovalResult.itemNotFound;
}
return RosterRemovalResult.error;
}
return RosterRemovalResult.okay;
}