From 8e7947926cd00a05f90a9d0bfdc29dcd2dc9ab7a Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 1 Jul 2020 13:35:58 +0100 Subject: [PATCH] Fix Yggdrasil gobind build, set display name at registration --- build/gobind/monolith.go | 11 +++++++++++ cmd/dendrite-demo-yggdrasil/yggconn/node.go | 4 ++++ userapi/internal/api.go | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/build/gobind/monolith.go b/build/gobind/monolith.go index 750babad8..62ca17447 100644 --- a/build/gobind/monolith.go +++ b/build/gobind/monolith.go @@ -11,6 +11,7 @@ import ( "github.com/matrix-org/dendrite/appservice" "github.com/matrix-org/dendrite/cmd/dendrite-demo-yggdrasil/signing" "github.com/matrix-org/dendrite/cmd/dendrite-demo-yggdrasil/yggconn" + "github.com/matrix-org/dendrite/currentstateserver" "github.com/matrix-org/dendrite/eduserver" "github.com/matrix-org/dendrite/eduserver/cache" "github.com/matrix-org/dendrite/federationsender" @@ -25,6 +26,7 @@ import ( ) type DendriteMonolith struct { + YggdrasilNode *yggconn.Node StorageDirectory string listener net.Listener } @@ -33,6 +35,10 @@ func (m *DendriteMonolith) BaseURL() string { return fmt.Sprintf("http://%s", m.listener.Addr().String()) } +func (m *DendriteMonolith) PeerCount() int { + return m.YggdrasilNode.PeerCount() +} + func (m *DendriteMonolith) Start() { logger := logrus.Logger{ Out: BindLogger{}, @@ -49,6 +55,7 @@ func (m *DendriteMonolith) Start() { if err != nil { panic(err) } + m.YggdrasilNode = ygg cfg := &config.Dendrite{} cfg.SetDefaults() @@ -69,6 +76,7 @@ func (m *DendriteMonolith) Start() { cfg.Database.FederationSender = config.DataSource(fmt.Sprintf("file:%s/dendrite-federationsender.db", m.StorageDirectory)) cfg.Database.AppService = config.DataSource(fmt.Sprintf("file:%s/dendrite-appservice.db", m.StorageDirectory)) cfg.Database.PublicRoomsAPI = config.DataSource(fmt.Sprintf("file:%s/dendrite-publicroomsa.db", m.StorageDirectory)) + cfg.Database.CurrentState = config.DataSource(fmt.Sprintf("file:%s/dendrite-currentstate.db", m.StorageDirectory)) cfg.Database.Naffka = config.DataSource(fmt.Sprintf("file:%s/dendrite-naffka.db", m.StorageDirectory)) if err = cfg.Derive(); err != nil { panic(err) @@ -108,6 +116,8 @@ func (m *DendriteMonolith) Start() { logrus.WithError(err).Panicf("failed to connect to public rooms db") } + stateAPI := currentstateserver.NewInternalAPI(base.Cfg, base.KafkaConsumer) + monolith := setup.Monolith{ Config: base.Cfg, AccountDB: accountDB, @@ -123,6 +133,7 @@ func (m *DendriteMonolith) Start() { FederationSenderAPI: fsAPI, RoomserverAPI: rsAPI, UserAPI: userAPI, + StateAPI: stateAPI, //ServerKeyAPI: serverKeyAPI, PublicRoomsDB: publicRoomsDB, diff --git a/cmd/dendrite-demo-yggdrasil/yggconn/node.go b/cmd/dendrite-demo-yggdrasil/yggconn/node.go index c335f2eac..73e9cd5b3 100644 --- a/cmd/dendrite-demo-yggdrasil/yggconn/node.go +++ b/cmd/dendrite-demo-yggdrasil/yggconn/node.go @@ -174,3 +174,7 @@ func (n *Node) SigningPrivateKey() ed25519.PrivateKey { privBytes, _ := hex.DecodeString(n.config.SigningPrivateKey) return ed25519.PrivateKey(privBytes) } + +func (n *Node) PeerCount() int { + return len(n.core.GetSwitchPeers()) +} diff --git a/userapi/internal/api.go b/userapi/internal/api.go index b081eca49..1d10d1d8b 100644 --- a/userapi/internal/api.go +++ b/userapi/internal/api.go @@ -85,6 +85,11 @@ func (a *UserInternalAPI) PerformAccountCreation(ctx context.Context, req *api.P } return nil } + + if err = a.AccountDB.SetDisplayName(ctx, req.Localpart, req.Localpart); err != nil { + return err + } + res.AccountCreated = true res.Account = acc return nil