sum7
/
yaja
Archived
1
0
Fork 0
This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
yaja/server/extension/iq_private_metacontacts.bak

52 lines
985 B
Plaintext
Raw Normal View History

package extension
import (
"encoding/xml"
"dev.sum7.eu/genofire/yaja/xmpp"
2018-02-10 13:34:42 +01:00
"dev.sum7.eu/genofire/yaja/model"
2018-02-07 15:34:18 +01:00
"dev.sum7.eu/genofire/yaja/server/utils"
)
2017-12-17 15:39:36 +01:00
type IQPrivateMetacontact struct {
2018-02-10 13:34:42 +01:00
IQExtension
}
func (ex *IQPrivateMetacontact) Handle(msg *xmpp.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{}
2017-12-17 17:50:51 +01:00
if err := xml.Unmarshal(q.Body, s); err != nil {
return false
}
/*
TODO full implement XEP-0209
https://xmpp.org/extensions/xep-0209.html
*/
2017-12-17 15:39:36 +01:00
queryByte, err := xml.Marshal(&iqPrivateQuery{
Body: q.Body,
})
if err != nil {
log.Warn(err)
return true
}
// reply
client.Messages <- &xmpp.IQClient{
Type: xmpp.IQTypeResult,
2018-02-10 13:34:42 +01:00
To: client.JID,
From: xmpp.NewJID(client.JID.Domain),
ID: msg.ID,
Body: queryByte,
2017-12-17 15:39:36 +01:00
}
log.Debug("send")
return true
}