xmpp: Fix bug in the blocking implementation

This commit is contained in:
PapaTutuWawa 2022-03-13 18:26:39 +01:00
parent 8a5b0ebdc3
commit 8f6af3c483

View File

@ -61,7 +61,7 @@ class BlockingManager extends XmppManagerBase {
return state.copyWith(done: true); return state.copyWith(done: true);
} }
Future<bool> block(String item) async { Future<bool> block(List<String> items) async {
final result = await getAttributes().sendStanza( final result = await getAttributes().sendStanza(
Stanza.iq( Stanza.iq(
type: "set", type: "set",
@ -69,12 +69,10 @@ class BlockingManager extends XmppManagerBase {
XMLNode.xmlns( XMLNode.xmlns(
tag: "unblock", tag: "unblock",
xmlns: blockingXmlns, xmlns: blockingXmlns,
children: [ children: items.map((item) => XMLNode(
XMLNode(
tag: "item", tag: "item",
attributes: { "jid": item } attributes: { "jid": item }
) )).toList()
]
) )
] ]
) )
@ -99,20 +97,20 @@ class BlockingManager extends XmppManagerBase {
return result.attributes["type"] == "result"; return result.attributes["type"] == "result";
} }
Future<bool> unblock(String item) async { Future<bool> unblock(List<String> items) async {
assert(items.isNotEmpty);
final result = await getAttributes().sendStanza( final result = await getAttributes().sendStanza(
Stanza.iq( Stanza.iq(
type: "set", type: "set",
children: [ children: [
XMLNode.xmlns( XMLNode.xmlns(
tag: "block", tag: "unblock",
xmlns: blockingXmlns, xmlns: blockingXmlns,
children: [ children: items.map((item) => XMLNode(
XMLNode(
tag: "item", tag: "item",
attributes: { "jid": item } attributes: { "jid": item }
) )).toList()
]
) )
] ]
) )