Compare commits

...

9 Commits

@ -56,6 +56,8 @@ type CommandElement interface {
}
type Actions struct {
XMLName xml.Name `xml:"actions"`
Prev *struct{} `xml:"prev,omitempty"`
Next *struct{} `xml:"next,omitempty"`
Complete *struct{} `xml:"complete,omitempty"`
@ -68,6 +70,8 @@ func (a *Actions) Ref() string {
}
type Note struct {
XMLName xml.Name `xml:"note"`
Text string `xml:",cdata"`
Type string `xml:"type,attr,omitempty"`
}
@ -117,11 +121,11 @@ func (c *Command) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
var err error
switch tt.Name.Local {
case "affiliations":
case "actions":
a := Actions{}
err = d.DecodeElement(&a, &tt)
c.CommandElement = &a
case "configure":
case "note":
nt := Note{}
err = d.DecodeElement(&nt, &tt)
c.CommandElement = &nt

@ -21,6 +21,7 @@ type DiscoInfo struct {
Identity []Identity `xml:"identity"`
Features []Feature `xml:"feature"`
ResultSet *ResultSet `xml:"set,omitempty"`
Form *Form `xml:"x,omitempty"`
}
// Namespace lets DiscoInfo implement the IQPayload interface

@ -16,6 +16,7 @@ func TestDiscoInfo_Builder(t *testing.T) {
disco := iq.DiscoInfo()
disco.AddIdentity("Test Component", "gateway", "service")
disco.AddFeatures(stanza.NSDiscoInfo, stanza.NSDiscoItems, "jabber:iq:version", "urn:xmpp:delegation:1")
disco.Form = stanza.NewForm([]*stanza.Field{}, "result")
parsedIQ, err := checkMarshalling(t, iq)
if err != nil {
@ -48,6 +49,15 @@ func TestDiscoInfo_Builder(t *testing.T) {
t.Errorf("Incorrect identity name: %#v", pp.Identity[0].Name)
}
}
// Check form
if pp.Form == nil {
t.Errorf("Form is nil")
} else {
if len(pp.Form.Fields) != 0 {
t.Errorf("Form fields length mismatch: %#v", pp.Form.Fields)
}
}
}
// Implements XEP-0030 example 17

@ -54,7 +54,7 @@ func (j *Jid) Full() string {
if j.Resource == "" {
return j.Bare()
} else if j.Node == "" {
return j.Node + "/" + j.Resource
return j.Domain + "/" + j.Resource
} else {
return j.Node + "@" + j.Domain + "/" + j.Resource
}

@ -63,6 +63,7 @@ func TestIncorrectJids(t *testing.T) {
func TestFull(t *testing.T) {
fullJids := []string{
"test@domain.com/my resource",
"domain.com/my resource",
"test@domain.com",
"domain.com",
}

Loading…
Cancel
Save