From 4f1e0ded9789319a710c70884927d613f9f28917 Mon Sep 17 00:00:00 2001 From: Mickael Remond Date: Tue, 9 Jul 2019 18:09:23 +0200 Subject: [PATCH] Simplify disco with builder helpers --- _examples/delegation/delegation.go | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/_examples/delegation/delegation.go b/_examples/delegation/delegation.go index 31c18d3..fcf397a 100644 --- a/_examples/delegation/delegation.go +++ b/_examples/delegation/delegation.go @@ -99,26 +99,9 @@ func discoInfo(c xmpp.Sender, p stanza.Packet, opts xmpp.ComponentOptions) { } func discoInfoRoot(iqResp *stanza.IQ, opts xmpp.ComponentOptions) { - // Higher level discovery - identity := stanza.Identity{ - Name: opts.Name, - Category: opts.Category, - Type: opts.Type, - } - payload := stanza.DiscoInfo{ - XMLName: xml.Name{ - Space: stanza.NSDiscoInfo, - Local: "query", - }, - Identity: []stanza.Identity{identity}, - Features: []stanza.Feature{ - {Var: stanza.NSDiscoInfo}, - {Var: stanza.NSDiscoItems}, - {Var: "jabber:iq:version"}, - {Var: "urn:xmpp:delegation:1"}, - }, - } - iqResp.Payload = &payload + disco := iqResp.DiscoInfo() + disco.AddIdentity(opts.Name, opts.Category, opts.Type) + disco.AddFeatures(stanza.NSDiscoInfo, stanza.NSDiscoItems, "jabber:iq:version", "urn:xmpp:delegation:1") } func discoInfoPubSub(iqResp *stanza.IQ) {