54 lines
1.5 KiB
Go
54 lines
1.5 KiB
Go
package main
|
|
|
|
// Implementation of XEP-0054
|
|
// https://xmpp.org/extensions/xep-0054.html
|
|
|
|
import (
|
|
"encoding/xml"
|
|
"gosrc.io/xmpp/stanza"
|
|
)
|
|
|
|
type VCard struct {
|
|
XMLName xml.Name `xml:"vcard-temp vCard"`
|
|
FirstName string `xml:"FN"`
|
|
LastName string `xml:"N>FAMILY"`
|
|
GivenName string `xml:"N>GIVEN"`
|
|
MiddleName string `xml:"N>MIDDLE"`
|
|
Nickname string `xml:"NICKNAME"`
|
|
URI string `xml:"URL"`
|
|
Birthday string `xml:"BDAY"`
|
|
OrgName string `xml:"ORG>ORGNAME"`
|
|
OrgUnit string `xml:"ORG>ORGUNIT"`
|
|
Title string `xml:"TITLE"`
|
|
Role string `xml:"ROLE"`
|
|
Description string `xml:"DESC"`
|
|
Jid string `xml:"JABBERID"`
|
|
Photo Photo `xml:"PHOTO"`
|
|
Email string `xml:"EMAIL>USERID"`
|
|
ResultSet *stanza.ResultSet `xml:"set,omitempty"`
|
|
}
|
|
|
|
type VCardUpdate struct {
|
|
stanza.PresExtension
|
|
XMLName xml.Name `xml:"vcard-temp:x:update x"`
|
|
Photo string `xml:"photo"`
|
|
}
|
|
|
|
func (v *VCard) Namespace() string {
|
|
return v.XMLName.Space
|
|
}
|
|
|
|
func (v *VCard) GetSet() *stanza.ResultSet {
|
|
return v.ResultSet
|
|
}
|
|
|
|
type Photo struct {
|
|
Type string `xml:"TYPE"`
|
|
Binval string `xml:"BINVAL"`
|
|
}
|
|
|
|
func init() {
|
|
stanza.TypeRegistry.MapExtension(stanza.PKTIQ, xml.Name{Space: "vcard-temp", Local: "vCard"}, VCard{})
|
|
stanza.TypeRegistry.MapExtension(stanza.PKTPresence, xml.Name{Space: "vcard-temp:x:update", Local: "x"}, VCardUpdate{})
|
|
}
|