2017-12-17 15:39:36 +01:00
|
|
|
package extension
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/xml"
|
|
|
|
|
2018-02-07 15:34:18 +01:00
|
|
|
"dev.sum7.eu/genofire/yaja/messages"
|
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 IQPrivateBookmark struct {
|
2018-02-10 13:34:42 +01:00
|
|
|
IQExtension
|
2017-12-17 15:39:36 +01:00
|
|
|
}
|
|
|
|
|
2018-02-10 13:34:42 +01:00
|
|
|
func (ex *IQPrivateBookmark) Handle(msg *messages.IQClient, client *utils.Client) bool {
|
2017-12-17 15:39:36 +01:00
|
|
|
log := client.Log.WithField("extension", "private").WithField("id", msg.ID)
|
|
|
|
|
|
|
|
// storage encode
|
|
|
|
type storage struct {
|
|
|
|
XMLName xml.Name `xml:"storage:bookmarks storage"`
|
|
|
|
}
|
|
|
|
s := &storage{}
|
2017-12-17 17:50:51 +01:00
|
|
|
if err := xml.Unmarshal(q.Body, s); err != nil {
|
2017-12-17 15:39:36 +01:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
TODO full implement
|
|
|
|
*/
|
|
|
|
|
|
|
|
queryByte, err := xml.Marshal(&iqPrivateQuery{
|
|
|
|
Body: q.Body,
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
log.Warn(err)
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
// reply
|
2018-02-07 19:32:11 +01:00
|
|
|
client.Messages <- &messages.IQClient{
|
2017-12-17 15:39:36 +01:00
|
|
|
Type: messages.IQTypeResult,
|
2018-02-10 13:34:42 +01:00
|
|
|
To: client.JID,
|
2018-02-13 20:05:18 +01:00
|
|
|
From: messages.NewJID(client.JID.Domain),
|
2017-12-17 15:39:36 +01:00
|
|
|
ID: msg.ID,
|
|
|
|
Body: queryByte,
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Debug("send")
|
|
|
|
|
|
|
|
return true
|
|
|
|
}
|