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.
This commit is contained in:
Kegsay 2020-06-02 15:01:13 +01:00 committed by GitHub
parent 794c63e757
commit 02b150fd13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 44 additions and 31 deletions

View file

@ -22,23 +22,24 @@ import (
"github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/dendrite/publicroomsapi/storage/postgres"
"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 NewPublicRoomsServerDatabase(dataSourceName string, dbProperties internal.DbProperties) (Database, error) {
func NewPublicRoomsServerDatabase(dataSourceName string, dbProperties internal.DbProperties, localServerName gomatrixserverlib.ServerName) (Database, error) {
uri, err := url.Parse(dataSourceName)
if err != nil {
return postgres.NewPublicRoomsServerDatabase(dataSourceName, dbProperties)
return postgres.NewPublicRoomsServerDatabase(dataSourceName, dbProperties, localServerName)
}
switch uri.Scheme {
case schemePostgres:
return postgres.NewPublicRoomsServerDatabase(dataSourceName, dbProperties)
return postgres.NewPublicRoomsServerDatabase(dataSourceName, dbProperties, localServerName)
case schemeFile:
return sqlite3.NewPublicRoomsServerDatabase(dataSourceName)
return sqlite3.NewPublicRoomsServerDatabase(dataSourceName, localServerName)
default:
return postgres.NewPublicRoomsServerDatabase(dataSourceName, dbProperties)
return postgres.NewPublicRoomsServerDatabase(dataSourceName, dbProperties, localServerName)
}
}