~samwhited/xmpp

f19cda0a944f4ba3d44fbe32376f03a36017234f — Sam Whited 4 years ago 5572f7f
Add some structs for out of band data
1 files changed, 43 insertions(+), 0 deletions(-)

A oob/oob.go
A oob/oob.go => oob/oob.go +43 -0
@@ 0,0 1,43 @@
// Copyright 2017 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.

// The oob package implements XEP-0066: Out of Band Data.
package oob // import "mellium.im/xmpp/oob"

import (
	"encoding/xml"

	"mellium.im/xmpp"
)

// IQ represents an OOB data query; for instance:
//
//     <iq type='set'
//         from='feste@example.net/asegasd'
//         to='malvolio@jabber.org/apkjase'
//         id='asiepjg'>
//       <query xmlns='jabber:iq:oob'>
//         <url>https://xmpp.org/images/promo/xmpp_server_guide_2017.pdf</url>
//         <desc>XMPP Server Setup Guide 2017</desc>
//       </query>
//     </iq>
type IQ struct {
	xmpp.IQ
	Query Query
}

// Query represents an OOB data node that might be placed in an IQ stanza.
type Query struct {
	XMLName xml.Name `xml:"jabber:iq:oob query"`
	URL     string   `xml:"url"`
	Desc    string   `xml:"desc,omitempty"`
}

// Data represents an OOB data node that might be placed in a message or
// presence stanza.
type Data struct {
	XMLName xml.Name `xml:"jabber:x:oob x"`
	URL     string   `xml:"url"`
	Desc    string   `xml:"desc,omitempty"`
}