aboutsummaryrefslogtreecommitdiff
path: root/xmpp
diff options
context:
space:
mode:
authorbodqhrohro <bodqhrohro@gmail.com>2019-11-11 02:50:50 +0300
committerbodqhrohro <bodqhrohro@gmail.com>2019-11-11 02:50:50 +0300
commitfbe99c65ec36bb0d8b3a508e0894a9830ff9c995 (patch)
treecaf1a1ced752de2e4188c383de82ba98f8bc9272 /xmpp
parent7185d4ac9b039bbb74291f57ee2dae6120c636f6 (diff)
Implementation of Ruby YAML::Store and read/save of the session database
Diffstat (limited to 'xmpp')
-rw-r--r--xmpp/component.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/xmpp/component.go b/xmpp/component.go
index 036bc3c..fcef91b 100644
--- a/xmpp/component.go
+++ b/xmpp/component.go
@@ -2,6 +2,7 @@ package xmpp
import (
"dev.narayana.im/narayana/telegabber/config"
+ "dev.narayana.im/narayana/telegabber/persistence"
"dev.narayana.im/narayana/telegabber/telegram"
"gosrc.io/xmpp"
@@ -10,11 +11,13 @@ import (
var jid *xmpp.Jid
var tgConf config.TelegramConfig
var sessions map[string]telegram.Client
+var db persistence.SessionsYamlDB
// NewComponent starts a new component and wraps it in
// a stream manager that you should start yourself
func NewComponent(conf config.XMPPConfig, tc config.TelegramConfig) (*xmpp.StreamManager, error) {
var err error
+
jid, err = xmpp.NewJid(conf.Jid)
if err != nil {
return nil, err
@@ -23,6 +26,11 @@ func NewComponent(conf config.XMPPConfig, tc config.TelegramConfig) (*xmpp.Strea
tgConf = tc
sessions = make(map[string]telegram.Client)
+ db, err = persistence.LoadSessions(conf.Db)
+ if err != nil {
+ return nil, err
+ }
+
options := xmpp.ComponentOptions{
Address: conf.Host + ":" + conf.Port,
Domain: conf.Jid,