forked from jshiffer/go-xmpp
fix everything
This commit is contained in:
parent
6fbfe9fd0a
commit
1971772394
@ -18,10 +18,10 @@ type MucPresence struct {
|
|||||||
|
|
||||||
// History implements XEP-0045: Multi-User Chat - 19.1
|
// History implements XEP-0045: Multi-User Chat - 19.1
|
||||||
type History struct {
|
type History struct {
|
||||||
MaxChars int `xml:"maxchars,attr,omitempty"`
|
MaxChars *int `xml:"maxchars,attr,omitempty"`
|
||||||
MaxStanzas int `xml:"maxstanzas,attr,omitempty"`
|
MaxStanzas *int `xml:"maxstanzas,attr,omitempty"`
|
||||||
Seconds int `xml:"seconds,attr,omitempty"`
|
Seconds *int `xml:"seconds,attr,omitempty"`
|
||||||
Since time.Time `xml:"since,attr,omitempty"`
|
Since *time.Time `xml:"since,attr,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -54,21 +54,23 @@ func TestMucHistory(t *testing.T) {
|
|||||||
t.Error("muc presence extension was not found")
|
t.Error("muc presence extension was not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
if muc.History.MaxStanzas != 20 {
|
if *muc.History.MaxStanzas != 20 {
|
||||||
t.Errorf("incorrect max stanza: '%d'", muc.History.MaxStanzas)
|
t.Errorf("incorrect max stanza: '%d'", muc.History.MaxStanzas)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xmpp.org/extensions/xep-0045.html#example-37
|
// https://xmpp.org/extensions/xep-0045.html#example-37
|
||||||
func TestMucNoHistory(t *testing.T) {
|
func TestMucNoHistory(t *testing.T) {
|
||||||
str := `<presence
|
str := "<presence" +
|
||||||
from='hag66@shakespeare.lit/pda'
|
" id=\"n13mt3l\"" +
|
||||||
id='n13mt3l'
|
" from=\"hag66@shakespeare.lit/pda\"" +
|
||||||
to='coven@chat.shakespeare.lit/thirdwitch'>
|
" to=\"coven@chat.shakespeare.lit/thirdwitch\">" +
|
||||||
<x xmlns='http://jabber.org/protocol/muc'>
|
"<x xmlns=\"http://jabber.org/protocol/muc\">" +
|
||||||
<history maxstanzas='0'/>
|
"<history maxstanzas=\"0\"></history>" +
|
||||||
</x>
|
"</x>" +
|
||||||
</presence>`
|
"</presence>"
|
||||||
|
|
||||||
|
maxstanzas := 0
|
||||||
|
|
||||||
pres := xmpp.Presence{Attrs: xmpp.Attrs{
|
pres := xmpp.Presence{Attrs: xmpp.Attrs{
|
||||||
From: "hag66@shakespeare.lit/pda",
|
From: "hag66@shakespeare.lit/pda",
|
||||||
@ -77,7 +79,7 @@ func TestMucNoHistory(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Extensions: []xmpp.PresExtension{
|
Extensions: []xmpp.PresExtension{
|
||||||
xmpp.MucPresence{
|
xmpp.MucPresence{
|
||||||
History: xmpp.History{MaxStanzas: 0},
|
History: xmpp.History{MaxStanzas: &maxstanzas},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -86,7 +88,7 @@ func TestMucNoHistory(t *testing.T) {
|
|||||||
t.Error("error on encode:", err)
|
t.Error("error on encode:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if data != str {
|
if string(data) != str {
|
||||||
t.Errorf("incorrect max stanza: '%d'", muc.History.MaxStanzas)
|
t.Errorf("incorrect stanza: \n%s\n%s", str, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user