51 lines
927 B
Plaintext
51 lines
927 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 IQPrivateBookmark struct {
|
|
IQExtension
|
|
}
|
|
|
|
func (ex *IQPrivateBookmark) Handle(msg *messages.IQClient, client *utils.Client) bool {
|
|
log := client.Log.WithField("extension", "private").WithField("id", msg.ID)
|
|
|
|
// storage encode
|
|
type storage struct {
|
|
XMLName xml.Name `xml:"storage:bookmarks storage"`
|
|
}
|
|
s := &storage{}
|
|
if err := xml.Unmarshal(q.Body, s); err != nil {
|
|
return false
|
|
}
|
|
/*
|
|
TODO full implement
|
|
*/
|
|
|
|
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
|
|
}
|