52 lines
1002 B
Plaintext
52 lines
1002 B
Plaintext
package extension
|
|
|
|
import (
|
|
"encoding/xml"
|
|
|
|
"dev.sum7.eu/genofire/yaja/messages"
|
|
"dev.sum7.eu/genofire/yaja/model"
|
|
"dev.sum7.eu/genofire/yaja/server/utils"
|
|
)
|
|
|
|
type IQPrivateMetacontact struct {
|
|
IQExtension
|
|
}
|
|
|
|
func (ex *IQPrivateMetacontact) Handle(msg *messages.IQClient, client *utils.Client) bool {
|
|
log := client.Log.WithField("extension", "private-metacontact").WithField("id", msg.ID)
|
|
|
|
// storage encode
|
|
type storage struct {
|
|
XMLName xml.Name `xml:"storage:metacontacts storage"`
|
|
}
|
|
s := &storage{}
|
|
if err := xml.Unmarshal(q.Body, s); err != nil {
|
|
return false
|
|
}
|
|
/*
|
|
TODO full implement XEP-0209
|
|
https://xmpp.org/extensions/xep-0209.html
|
|
*/
|
|
|
|
queryByte, err := xml.Marshal(&iqPrivateQuery{
|
|
Body: q.Body,
|
|
})
|
|
if err != nil {
|
|
log.Warn(err)
|
|
return true
|
|
}
|
|
|
|
// reply
|
|
client.Messages <- &messages.IQClient{
|
|
Type: messages.IQTypeResult,
|
|
To: client.JID,
|
|
From: model.NewJID(client.JID.Domain),
|
|
ID: msg.ID,
|
|
Body: queryByte,
|
|
}
|
|
|
|
log.Debug("send")
|
|
|
|
return true
|
|
}
|