Compare commits
No commits in common. "process-one-is-lazy" and "160-regression" have entirely different histories.
process-on
...
160-regres
|
@ -23,7 +23,7 @@ const (
|
|||
type Command struct {
|
||||
XMLName xml.Name `xml:"http://jabber.org/protocol/commands command"`
|
||||
|
||||
CommandElements []CommandElement
|
||||
CommandElement CommandElement
|
||||
|
||||
BadAction *struct{} `xml:"bad-action,omitempty"`
|
||||
BadLocale *struct{} `xml:"bad-locale,omitempty"`
|
||||
|
@ -56,8 +56,6 @@ 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"`
|
||||
|
@ -70,8 +68,6 @@ func (a *Actions) Ref() string {
|
|||
}
|
||||
|
||||
type Note struct {
|
||||
XMLName xml.Name `xml:"note"`
|
||||
|
||||
Text string `xml:",cdata"`
|
||||
Type string `xml:"type,attr,omitempty"`
|
||||
}
|
||||
|
@ -121,22 +117,22 @@ func (c *Command) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
|
|||
var err error
|
||||
switch tt.Name.Local {
|
||||
|
||||
case "actions":
|
||||
case "affiliations":
|
||||
a := Actions{}
|
||||
err = d.DecodeElement(&a, &tt)
|
||||
c.CommandElements = append(c.CommandElements, &a)
|
||||
case "note":
|
||||
c.CommandElement = &a
|
||||
case "configure":
|
||||
nt := Note{}
|
||||
err = d.DecodeElement(&nt, &tt)
|
||||
c.CommandElements = append(c.CommandElements, &nt)
|
||||
c.CommandElement = &nt
|
||||
case "x":
|
||||
f := Form{}
|
||||
err = d.DecodeElement(&f, &tt)
|
||||
c.CommandElements = append(c.CommandElements, &f)
|
||||
c.CommandElement = &f
|
||||
default:
|
||||
n := Node{}
|
||||
err = d.DecodeElement(&n, &tt)
|
||||
c.CommandElements = append(c.CommandElements, &n)
|
||||
c.CommandElement = &n
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ 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,7 +16,6 @@ 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 {
|
||||
|
@ -49,15 +48,6 @@ 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.Domain + "/" + j.Resource
|
||||
return j.Node + "/" + j.Resource
|
||||
} else {
|
||||
return j.Node + "@" + j.Domain + "/" + j.Resource
|
||||
}
|
||||
|
|
|
@ -63,7 +63,6 @@ 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",
|
||||
}
|
||||
|
|
|
@ -237,10 +237,10 @@ func NewApprovePendingSubRequest(serviceId, sessionId, nodeId string) (*IQ, erro
|
|||
}
|
||||
iq.Payload = &Command{
|
||||
// the command name ('node' attribute of the command element) MUST have a value of "http://jabber.org/protocol/pubsub#get-pending"
|
||||
Node: "http://jabber.org/protocol/pubsub#get-pending",
|
||||
Action: CommandActionExecute,
|
||||
SessionId: sessionId,
|
||||
CommandElements: []CommandElement{&n},
|
||||
Node: "http://jabber.org/protocol/pubsub#get-pending",
|
||||
Action: CommandActionExecute,
|
||||
SessionId: sessionId,
|
||||
CommandElement: &n,
|
||||
}
|
||||
return iq, nil
|
||||
}
|
||||
|
@ -353,18 +353,11 @@ func (iq *IQ) GetFormFields() (map[string]*Field, error) {
|
|||
|
||||
case *Command:
|
||||
fieldMap := make(map[string]*Field)
|
||||
var form *Form
|
||||
for _, ce := range payload.CommandElements {
|
||||
fo, ok := ce.(*Form)
|
||||
if ok {
|
||||
form = fo
|
||||
break
|
||||
}
|
||||
}
|
||||
if form == nil {
|
||||
co, ok := payload.CommandElement.(*Form)
|
||||
if !ok {
|
||||
return nil, errors.New("this IQ does not contain a command payload with a form")
|
||||
}
|
||||
for _, elt := range form.Fields {
|
||||
for _, elt := range co.Fields {
|
||||
fieldMap[elt.Var] = elt
|
||||
}
|
||||
return fieldMap, nil
|
||||
|
|
Loading…
Reference in a new issue