aboutsummaryrefslogtreecommitdiff
path: root/xmpp
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp')
-rw-r--r--xmpp/component.go12
-rw-r--r--xmpp/extensions/extensions.go6
-rw-r--r--xmpp/gateway/gateway.go2
-rw-r--r--xmpp/handlers.go12
4 files changed, 22 insertions, 10 deletions
diff --git a/xmpp/component.go b/xmpp/component.go
index bbf0483..d1d0ddf 100644
--- a/xmpp/component.go
+++ b/xmpp/component.go
@@ -11,6 +11,7 @@ import (
log "github.com/sirupsen/logrus"
"gosrc.io/xmpp"
+ "gosrc.io/xmpp/stanza"
)
var tgConf config.TelegramConfig
@@ -22,7 +23,7 @@ var db *persistence.SessionsYamlDB
func NewComponent(conf config.XMPPConfig, tc config.TelegramConfig) (*xmpp.StreamManager, *xmpp.Component, error) {
var err error
- gateway.Jid, err = xmpp.NewJid(conf.Jid)
+ gateway.Jid, err = stanza.NewJid(conf.Jid)
if err != nil {
return nil, nil, err
}
@@ -30,7 +31,10 @@ func NewComponent(conf config.XMPPConfig, tc config.TelegramConfig) (*xmpp.Strea
tgConf = tc
options := xmpp.ComponentOptions{
- Address: conf.Host + ":" + conf.Port,
+ TransportConfiguration: xmpp.TransportConfiguration{
+ Address: conf.Host + ":" + conf.Port,
+ Domain: conf.Jid,
+ },
Domain: conf.Jid,
Secret: conf.Password,
Name: "telegabber",
@@ -41,7 +45,9 @@ func NewComponent(conf config.XMPPConfig, tc config.TelegramConfig) (*xmpp.Strea
router.HandleFunc("presence", HandlePresence)
router.HandleFunc("message", HandleMessage)
- component, err := xmpp.NewComponent(options, router)
+ component, err := xmpp.NewComponent(options, router, func(err error) {
+ log.Error(err)
+ })
if err != nil {
return nil, nil, err
}
diff --git a/xmpp/extensions/extensions.go b/xmpp/extensions/extensions.go
index 594140f..ea00008 100644
--- a/xmpp/extensions/extensions.go
+++ b/xmpp/extensions/extensions.go
@@ -32,6 +32,7 @@ type IqVcardTemp struct {
N IqVcardN
Tel IqVcardTel
Photo IqVcardPhoto
+ ResultSet *stanza.ResultSet `xml:"set,omitempty"`
}
// IqVcardFn is vCard/FN
@@ -118,6 +119,11 @@ func (c IqVcardTemp) Namespace() string {
return c.XMLName.Space
}
+// Namespace is a namespace!
+func (c IqVcardTemp) GetSet() *stanza.ResultSet {
+ return c.ResultSet
+}
+
func init() {
// presence nick
stanza.TypeRegistry.MapExtension(stanza.PKTPresence, xml.Name{
diff --git a/xmpp/gateway/gateway.go b/xmpp/gateway/gateway.go
index 01269d0..eb46e48 100644
--- a/xmpp/gateway/gateway.go
+++ b/xmpp/gateway/gateway.go
@@ -16,7 +16,7 @@ import (
var Queue = make(map[string]*stanza.Presence)
// Jid stores the component's JID object
-var Jid *xmpp.Jid
+var Jid *stanza.Jid
// SendMessage creates and sends a message stanza
func SendMessage(to string, from string, body string, component *xmpp.Component) {
diff --git a/xmpp/handlers.go b/xmpp/handlers.go
index 2e44411..ee767ad 100644
--- a/xmpp/handlers.go
+++ b/xmpp/handlers.go
@@ -24,7 +24,7 @@ func logPacketType(p stanza.Packet) {
// HandleIq processes an incoming XMPP iq
func HandleIq(s xmpp.Sender, p stanza.Packet) {
- iq, ok := p.(stanza.IQ)
+ iq, ok := p.(*stanza.IQ)
if !ok {
logPacketType(p)
return
@@ -60,7 +60,7 @@ func HandleMessage(s xmpp.Sender, p stanza.Packet) {
}).Warn("Message")
log.Debugf("%#v", msg)
- fromJid, err := xmpp.NewJid(msg.From)
+ fromJid, err := stanza.NewJid(msg.From)
if err != nil {
log.Error("Invalid from JID!")
return
@@ -155,7 +155,7 @@ func handlePresence(s xmpp.Sender, p stanza.Presence) {
log.Debugf("%#v", p)
// create session
- fromJid, err := xmpp.NewJid(p.From)
+ fromJid, err := stanza.NewJid(p.From)
if err != nil {
log.Error("Invalid from JID!")
return
@@ -196,13 +196,13 @@ func handlePresence(s xmpp.Sender, p stanza.Presence) {
}
}
-func handleGetVcardTempIq(s xmpp.Sender, iq stanza.IQ) {
+func handleGetVcardTempIq(s xmpp.Sender, iq *stanza.IQ) {
log.WithFields(log.Fields{
"from": iq.From,
"to": iq.To,
}).Warn("VCard request")
- fromJid, err := xmpp.NewJid(iq.From)
+ fromJid, err := stanza.NewJid(iq.From)
if err != nil {
log.Error("Invalid from JID!")
return
@@ -274,5 +274,5 @@ func handleGetVcardTempIq(s xmpp.Sender, iq stanza.IQ) {
return
}
- _ = gateway.ResumableSend(component, answer)
+ _ = gateway.ResumableSend(component, &answer)
}