Files
lambda/xmpp-vcard.go
T
2026-05-10 14:46:19 +01:00

55 lines
1.7 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,omitempty"`
LastName string `xml:"N>FAMILY,omitempty"`
GivenName string `xml:"N>GIVEN,omitempty"`
MiddleName string `xml:"N>MIDDLE,omitempty"`
Nickname string `xml:"NICKNAME,omitempty"`
URI string `xml:"URL,omitempty"`
Birthday string `xml:"BDAY,omitempty"`
OrgName string `xml:"ORG>ORGNAME,omitempty"`
OrgUnit string `xml:"ORG>ORGUNIT,omitempty"`
Title string `xml:"TITLE,omitempty"`
Role string `xml:"ROLE,omitempty"`
Description string `xml:"DESC,omitempty"`
Jid string `xml:"JABBERID,omitempty"`
Photo Photo `xml:"PHOTO,omitempty"`
Email string `xml:"EMAIL>USERID,omitempty"`
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{})
}