Extend Presence struct with real jid, affiliation and role info
This enables client to get full info about jids from MUCs presence notifications, if this feature enabled in MUC
This commit is contained in:
29
xmpp.go
29
xmpp.go
@@ -794,6 +794,11 @@ type Presence struct {
|
|||||||
Type string
|
Type string
|
||||||
Show string
|
Show string
|
||||||
Status string
|
Status string
|
||||||
|
Priority string
|
||||||
|
ID string
|
||||||
|
Affilation string
|
||||||
|
Role string
|
||||||
|
JID string
|
||||||
}
|
}
|
||||||
|
|
||||||
type IQ struct {
|
type IQ struct {
|
||||||
@@ -858,7 +863,18 @@ func (c *Client) Recv() (stanza interface{}, err error) {
|
|||||||
}
|
}
|
||||||
return Chat{Type: "roster", Roster: r}, nil
|
return Chat{Type: "roster", Roster: r}, nil
|
||||||
case *clientPresence:
|
case *clientPresence:
|
||||||
return Presence{v.From, v.To, v.Type, v.Show, v.Status}, nil
|
return Presence{
|
||||||
|
v.From,
|
||||||
|
v.To,
|
||||||
|
v.Type,
|
||||||
|
v.Show,
|
||||||
|
v.Status,
|
||||||
|
v.Priority,
|
||||||
|
v.ID,
|
||||||
|
v.X.Item.Affiliation,
|
||||||
|
v.X.Item.Role,
|
||||||
|
v.X.Item.Jid,
|
||||||
|
}, nil
|
||||||
case *clientIQ:
|
case *clientIQ:
|
||||||
switch {
|
switch {
|
||||||
case v.Query.XMLName.Space == "urn:xmpp:ping":
|
case v.Query.XMLName.Space == "urn:xmpp:ping":
|
||||||
@@ -1294,7 +1310,16 @@ type clientPresence struct {
|
|||||||
To string `xml:"to,attr"`
|
To string `xml:"to,attr"`
|
||||||
Type string `xml:"type,attr"` // error, probe, subscribe, subscribed, unavailable, unsubscribe, unsubscribed
|
Type string `xml:"type,attr"` // error, probe, subscribe, subscribed, unavailable, unsubscribe, unsubscribed
|
||||||
Lang string `xml:"lang,attr"`
|
Lang string `xml:"lang,attr"`
|
||||||
|
X struct {
|
||||||
|
Text string `xml:",chardata"`
|
||||||
|
Xmlns string `xml:"xmlns,attr"`
|
||||||
|
Item struct {
|
||||||
|
Text string `xml:",chardata"`
|
||||||
|
Affiliation string `xml:"affiliation,attr"`
|
||||||
|
Jid string `xml:"jid,attr"`
|
||||||
|
Role string `xml:"role,attr"`
|
||||||
|
} `xml:"item"`
|
||||||
|
} `xml:"x"`
|
||||||
Show string `xml:"show"` // away, chat, dnd, xa
|
Show string `xml:"show"` // away, chat, dnd, xa
|
||||||
Status string `xml:"status"` // sb []clientText
|
Status string `xml:"status"` // sb []clientText
|
||||||
Priority string `xml:"priority,attr"`
|
Priority string `xml:"priority,attr"`
|
||||||
|
|||||||
Reference in New Issue
Block a user