diff options
author | Kegsay <kegan@matrix.org> | 2020-06-02 15:01:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-02 15:01:13 +0100 |
commit | 02b150fd13f64bae551d5a7fd967caf4479981b8 (patch) | |
tree | 3fd3ae6b723ddfa7b2da068eb009f65242dc6405 /cmd | |
parent | 794c63e757ce59fb8f934099b6ca2b1ccc0fa31e (diff) |
Only store our own aliases in publicroomsapi (#1081)
Otherwise we just store the latest aliases submitted from a server,
which is not what we want.
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/dendrite-demo-libp2p/main.go | 2 | ||||
-rw-r--r-- | cmd/dendrite-demo-libp2p/storage/postgreswithdht/storage.go | 4 | ||||
-rw-r--r-- | cmd/dendrite-demo-libp2p/storage/postgreswithpubsub/storage.go | 4 | ||||
-rw-r--r-- | cmd/dendrite-demo-libp2p/storage/storage.go | 21 | ||||
-rw-r--r-- | cmd/dendrite-monolith-server/main.go | 2 | ||||
-rw-r--r-- | cmd/dendrite-public-rooms-api-server/main.go | 2 | ||||
-rw-r--r-- | cmd/dendritejs/main.go | 2 |
7 files changed, 19 insertions, 18 deletions
diff --git a/cmd/dendrite-demo-libp2p/main.go b/cmd/dendrite-demo-libp2p/main.go index e9d01fd9..c00316ec 100644 --- a/cmd/dendrite-demo-libp2p/main.go +++ b/cmd/dendrite-demo-libp2p/main.go @@ -166,7 +166,7 @@ func main() { eduProducer := producers.NewEDUServerProducer(eduInputAPI) federationapi.SetupFederationAPIComponent(&base.Base, accountDB, deviceDB, federation, keyRing, rsAPI, asAPI, fsAPI, eduProducer) mediaapi.SetupMediaAPIComponent(&base.Base, deviceDB) - publicRoomsDB, err := storage.NewPublicRoomsServerDatabaseWithPubSub(string(base.Base.Cfg.Database.PublicRoomsAPI), base.LibP2PPubsub) + publicRoomsDB, err := storage.NewPublicRoomsServerDatabaseWithPubSub(string(base.Base.Cfg.Database.PublicRoomsAPI), base.LibP2PPubsub, cfg.Matrix.ServerName) if err != nil { logrus.WithError(err).Panicf("failed to connect to public rooms db") } diff --git a/cmd/dendrite-demo-libp2p/storage/postgreswithdht/storage.go b/cmd/dendrite-demo-libp2p/storage/postgreswithdht/storage.go index cd2804c9..d2cb36a8 100644 --- a/cmd/dendrite-demo-libp2p/storage/postgreswithdht/storage.go +++ b/cmd/dendrite-demo-libp2p/storage/postgreswithdht/storage.go @@ -44,8 +44,8 @@ type PublicRoomsServerDatabase struct { } // NewPublicRoomsServerDatabase creates a new public rooms server database. -func NewPublicRoomsServerDatabase(dataSourceName string, dht *dht.IpfsDHT) (*PublicRoomsServerDatabase, error) { - pg, err := postgres.NewPublicRoomsServerDatabase(dataSourceName, nil) +func NewPublicRoomsServerDatabase(dataSourceName string, dht *dht.IpfsDHT, localServerName gomatrixserverlib.ServerName) (*PublicRoomsServerDatabase, error) { + pg, err := postgres.NewPublicRoomsServerDatabase(dataSourceName, nil, localServerName) if err != nil { return nil, err } diff --git a/cmd/dendrite-demo-libp2p/storage/postgreswithpubsub/storage.go b/cmd/dendrite-demo-libp2p/storage/postgreswithpubsub/storage.go index e4372c64..cf642eb3 100644 --- a/cmd/dendrite-demo-libp2p/storage/postgreswithpubsub/storage.go +++ b/cmd/dendrite-demo-libp2p/storage/postgreswithpubsub/storage.go @@ -47,8 +47,8 @@ type PublicRoomsServerDatabase struct { } // NewPublicRoomsServerDatabase creates a new public rooms server database. -func NewPublicRoomsServerDatabase(dataSourceName string, pubsub *pubsub.PubSub) (*PublicRoomsServerDatabase, error) { - pg, err := postgres.NewPublicRoomsServerDatabase(dataSourceName, nil) +func NewPublicRoomsServerDatabase(dataSourceName string, pubsub *pubsub.PubSub, localServerName gomatrixserverlib.ServerName) (*PublicRoomsServerDatabase, error) { + pg, err := postgres.NewPublicRoomsServerDatabase(dataSourceName, nil, localServerName) if err != nil { return nil, err } diff --git a/cmd/dendrite-demo-libp2p/storage/storage.go b/cmd/dendrite-demo-libp2p/storage/storage.go index 668edbaa..2d8dc181 100644 --- a/cmd/dendrite-demo-libp2p/storage/storage.go +++ b/cmd/dendrite-demo-libp2p/storage/storage.go @@ -23,39 +23,40 @@ import ( "github.com/matrix-org/dendrite/cmd/dendrite-demo-libp2p/storage/postgreswithpubsub" "github.com/matrix-org/dendrite/publicroomsapi/storage" "github.com/matrix-org/dendrite/publicroomsapi/storage/sqlite3" + "github.com/matrix-org/gomatrixserverlib" ) const schemePostgres = "postgres" const schemeFile = "file" // NewPublicRoomsServerDatabase opens a database connection. -func NewPublicRoomsServerDatabaseWithDHT(dataSourceName string, dht *dht.IpfsDHT) (storage.Database, error) { +func NewPublicRoomsServerDatabaseWithDHT(dataSourceName string, dht *dht.IpfsDHT, localServerName gomatrixserverlib.ServerName) (storage.Database, error) { uri, err := url.Parse(dataSourceName) if err != nil { - return postgreswithdht.NewPublicRoomsServerDatabase(dataSourceName, dht) + return postgreswithdht.NewPublicRoomsServerDatabase(dataSourceName, dht, localServerName) } switch uri.Scheme { case schemePostgres: - return postgreswithdht.NewPublicRoomsServerDatabase(dataSourceName, dht) + return postgreswithdht.NewPublicRoomsServerDatabase(dataSourceName, dht, localServerName) case schemeFile: - return sqlite3.NewPublicRoomsServerDatabase(dataSourceName) + return sqlite3.NewPublicRoomsServerDatabase(dataSourceName, localServerName) default: - return postgreswithdht.NewPublicRoomsServerDatabase(dataSourceName, dht) + return postgreswithdht.NewPublicRoomsServerDatabase(dataSourceName, dht, localServerName) } } // NewPublicRoomsServerDatabase opens a database connection. -func NewPublicRoomsServerDatabaseWithPubSub(dataSourceName string, pubsub *pubsub.PubSub) (storage.Database, error) { +func NewPublicRoomsServerDatabaseWithPubSub(dataSourceName string, pubsub *pubsub.PubSub, localServerName gomatrixserverlib.ServerName) (storage.Database, error) { uri, err := url.Parse(dataSourceName) if err != nil { - return postgreswithpubsub.NewPublicRoomsServerDatabase(dataSourceName, pubsub) + return postgreswithpubsub.NewPublicRoomsServerDatabase(dataSourceName, pubsub, localServerName) } switch uri.Scheme { case schemePostgres: - return postgreswithpubsub.NewPublicRoomsServerDatabase(dataSourceName, pubsub) + return postgreswithpubsub.NewPublicRoomsServerDatabase(dataSourceName, pubsub, localServerName) case schemeFile: - return sqlite3.NewPublicRoomsServerDatabase(dataSourceName) + return sqlite3.NewPublicRoomsServerDatabase(dataSourceName, localServerName) default: - return postgreswithpubsub.NewPublicRoomsServerDatabase(dataSourceName, pubsub) + return postgreswithpubsub.NewPublicRoomsServerDatabase(dataSourceName, pubsub, localServerName) } } diff --git a/cmd/dendrite-monolith-server/main.go b/cmd/dendrite-monolith-server/main.go index ef114ccd..41907cc0 100644 --- a/cmd/dendrite-monolith-server/main.go +++ b/cmd/dendrite-monolith-server/main.go @@ -120,7 +120,7 @@ func main() { eduProducer := producers.NewEDUServerProducer(eduInputAPI) federationapi.SetupFederationAPIComponent(base, accountDB, deviceDB, federation, keyRing, rsAPI, asAPI, fsAPI, eduProducer) mediaapi.SetupMediaAPIComponent(base, deviceDB) - publicRoomsDB, err := storage.NewPublicRoomsServerDatabase(string(base.Cfg.Database.PublicRoomsAPI), base.Cfg.DbProperties()) + publicRoomsDB, err := storage.NewPublicRoomsServerDatabase(string(base.Cfg.Database.PublicRoomsAPI), base.Cfg.DbProperties(), cfg.Matrix.ServerName) if err != nil { logrus.WithError(err).Panicf("failed to connect to public rooms db") } diff --git a/cmd/dendrite-public-rooms-api-server/main.go b/cmd/dendrite-public-rooms-api-server/main.go index cf9d09c1..d506e32d 100644 --- a/cmd/dendrite-public-rooms-api-server/main.go +++ b/cmd/dendrite-public-rooms-api-server/main.go @@ -32,7 +32,7 @@ func main() { rsAPI := base.CreateHTTPRoomserverAPIs() rsAPI.SetFederationSenderAPI(fsAPI) - publicRoomsDB, err := storage.NewPublicRoomsServerDatabase(string(base.Cfg.Database.PublicRoomsAPI), base.Cfg.DbProperties()) + publicRoomsDB, err := storage.NewPublicRoomsServerDatabase(string(base.Cfg.Database.PublicRoomsAPI), base.Cfg.DbProperties(), cfg.Matrix.ServerName) if err != nil { logrus.WithError(err).Panicf("failed to connect to public rooms db") } diff --git a/cmd/dendritejs/main.go b/cmd/dendritejs/main.go index 72008aa9..c1aef44d 100644 --- a/cmd/dendritejs/main.go +++ b/cmd/dendritejs/main.go @@ -223,7 +223,7 @@ func main() { eduProducer := producers.NewEDUServerProducer(eduInputAPI) federationapi.SetupFederationAPIComponent(base, accountDB, deviceDB, federation, &keyRing, rsAPI, asQuery, fedSenderAPI, eduProducer) mediaapi.SetupMediaAPIComponent(base, deviceDB) - publicRoomsDB, err := storage.NewPublicRoomsServerDatabase(string(base.Cfg.Database.PublicRoomsAPI)) + publicRoomsDB, err := storage.NewPublicRoomsServerDatabase(string(base.Cfg.Database.PublicRoomsAPI), cfg.Matrix.ServerName) if err != nil { logrus.WithError(err).Panicf("failed to connect to public rooms db") } |