aboutsummaryrefslogtreecommitdiff
path: root/xmpp
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2022-06-29 16:56:27 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2022-06-29 16:56:27 +0300
commit38ffdb9e4791652b09d59643c8e0b200c2566e1c (patch)
treefd64275dd2144b350b49e0fef9a998008bb204db /xmpp
parent76ac66236612315860538a73334e6c7d10c7c4b4 (diff)
Retrieve Bio / Description for vCard desc / note
Diffstat (limited to 'xmpp')
-rw-r--r--xmpp/extensions/extensions.go7
-rw-r--r--xmpp/handlers.go19
2 files changed, 23 insertions, 3 deletions
diff --git a/xmpp/extensions/extensions.go b/xmpp/extensions/extensions.go
index 878770a..fac5e7b 100644
--- a/xmpp/extensions/extensions.go
+++ b/xmpp/extensions/extensions.go
@@ -32,6 +32,7 @@ type IqVcardTemp struct {
N IqVcardN
Tel IqVcardTel
Photo IqVcardPhoto
+ Desc IqVcardDesc
ResultSet *stanza.ResultSet `xml:"set,omitempty"`
}
@@ -104,6 +105,12 @@ type IqVcardPhotoBinval struct {
Text string `xml:",chardata"`
}
+// IqVcardDesc is vCard/DESC
+type IqVcardDesc struct {
+ XMLName xml.Name `xml:"DESC"`
+ Text string `xml:",chardata"`
+}
+
// Namespace is a namespace!
func (c PresenceNickExtension) Namespace() string {
return c.XMLName.Space
diff --git a/xmpp/handlers.go b/xmpp/handlers.go
index 06bc02b..1222a93 100644
--- a/xmpp/handlers.go
+++ b/xmpp/handlers.go
@@ -260,7 +260,7 @@ func handleGetVcardIq(s xmpp.Sender, iq *stanza.IQ, typ byte) {
return
}
- var fn, photo, nickname, given, family, tel string
+ var fn, photo, nickname, given, family, tel, info string
if chat != nil {
fn = chat.Title
@@ -284,6 +284,7 @@ func handleGetVcardIq(s xmpp.Sender, iq *stanza.IQ, typ byte) {
log.Errorf("PHOTO: %#v", err.Error())
}
}
+ info = session.GetChatDescription(chat)
}
if user != nil {
nickname = user.Username
@@ -299,7 +300,7 @@ func handleGetVcardIq(s xmpp.Sender, iq *stanza.IQ, typ byte) {
Id: iq.Id,
Type: "result",
},
- Payload: makeVCardPayload(typ, iq.To, fn, photo, nickname, given, family, tel),
+ Payload: makeVCardPayload(typ, iq.To, fn, photo, nickname, given, family, tel, info),
}
log.Debugf("%#v", answer)
@@ -371,7 +372,7 @@ func toToID(to string) (int64, bool) {
return toID, true
}
-func makeVCardPayload(typ byte, id string, fn string, photo string, nickname string, given string, family string, tel string) stanza.IQPayload {
+func makeVCardPayload(typ byte, id, fn, photo, nickname, given, family, tel, info string) stanza.IQPayload {
if typ == TypeVCardTemp {
vcard := &extensions.IqVcardTemp{}
@@ -384,6 +385,7 @@ func makeVCardPayload(typ byte, id string, fn string, photo string, nickname str
vcard.N.Given.Text = given
vcard.N.Family.Text = family
vcard.Tel.Number.Text = tel
+ vcard.Desc.Text = info
return vcard
} else if typ == TypeVCard4 {
@@ -447,6 +449,17 @@ func makeVCardPayload(typ byte, id string, fn string, photo string, nickname str
},
})
}
+ if info != "" {
+ nodes = append(nodes, stanza.Node{
+ XMLName: xml.Name{Local: "note"},
+ Nodes: []stanza.Node{
+ stanza.Node{
+ XMLName: xml.Name{Local: "text"},
+ Content: info,
+ },
+ },
+ })
+ }
pubsub := &stanza.PubSubGeneric{
Items: &stanza.Items{