2017-12-17 13:31:02 +01:00
|
|
|
package extension
|
|
|
|
|
|
|
|
import (
|
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 13:31:02 +01:00
|
|
|
)
|
|
|
|
|
2017-12-17 15:39:36 +01:00
|
|
|
type IQPing struct {
|
2017-12-17 13:31:02 +01:00
|
|
|
IQExtension
|
|
|
|
}
|
|
|
|
|
2017-12-17 15:39:36 +01:00
|
|
|
func (ex *IQPing) Spaces() []string { return []string{"urn:xmpp:ping"} }
|
2017-12-17 13:31:02 +01:00
|
|
|
|
2018-02-07 19:32:11 +01:00
|
|
|
func (ex *IQPing) Get(msg *messages.IQClient, client *utils.Client) bool {
|
2017-12-17 13:31:02 +01:00
|
|
|
log := client.Log.WithField("extension", "ping").WithField("id", msg.ID)
|
|
|
|
|
2018-02-10 13:34:42 +01:00
|
|
|
if msg.Ping == nil {
|
2017-12-17 13:31:02 +01:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
// reply
|
2018-02-07 19:32:11 +01:00
|
|
|
client.Messages <- &messages.IQClient{
|
2017-12-17 13:31:02 +01:00
|
|
|
Type: messages.IQTypeResult,
|
2018-02-10 13:34:42 +01:00
|
|
|
To: client.JID,
|
|
|
|
From: model.NewJID(client.JID.Domain),
|
2017-12-17 13:31:02 +01:00
|
|
|
ID: msg.ID,
|
2017-12-17 15:39:36 +01:00
|
|
|
}
|
2017-12-17 13:31:02 +01:00
|
|
|
|
|
|
|
log.Debug("send")
|
|
|
|
|
|
|
|
return true
|
|
|
|
}
|