mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-02 14:12:47 +00:00
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:
parent
794c63e757
commit
02b150fd13
11 changed files with 44 additions and 31 deletions
|
@ -32,20 +32,22 @@ import (
|
|||
type PublicRoomsServerDatabase struct {
|
||||
db *sql.DB
|
||||
internal.PartitionOffsetStatements
|
||||
statements publicRoomsStatements
|
||||
statements publicRoomsStatements
|
||||
localServerName gomatrixserverlib.ServerName
|
||||
}
|
||||
|
||||
type attributeValue interface{}
|
||||
|
||||
// NewPublicRoomsServerDatabase creates a new public rooms server database.
|
||||
func NewPublicRoomsServerDatabase(dataSourceName string) (*PublicRoomsServerDatabase, error) {
|
||||
func NewPublicRoomsServerDatabase(dataSourceName string, localServerName gomatrixserverlib.ServerName) (*PublicRoomsServerDatabase, error) {
|
||||
var db *sql.DB
|
||||
var err error
|
||||
if db, err = sqlutil.Open(internal.SQLiteDriverName(), dataSourceName, nil); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
storage := PublicRoomsServerDatabase{
|
||||
db: db,
|
||||
db: db,
|
||||
localServerName: localServerName,
|
||||
}
|
||||
if err = storage.PartitionOffsetStatements.Prepare(db, "publicroomsapi"); err != nil {
|
||||
return nil, err
|
||||
|
@ -245,6 +247,9 @@ func (d *PublicRoomsServerDatabase) updateBooleanAttribute(
|
|||
func (d *PublicRoomsServerDatabase) updateRoomAliases(
|
||||
ctx context.Context, aliasesEvent gomatrixserverlib.Event,
|
||||
) error {
|
||||
if aliasesEvent.StateKey() == nil || *aliasesEvent.StateKey() != string(d.localServerName) {
|
||||
return nil // only store our own aliases
|
||||
}
|
||||
var content internal.AliasesContent
|
||||
if err := json.Unmarshal(aliasesEvent.Content(), &content); err != nil {
|
||||
return err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue