mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-16 11:23:11 -06:00
GetJoinedHosts from federation server db
This commit is contained in:
parent
dc89e04e7d
commit
b500f2bfb6
|
|
@ -97,10 +97,22 @@ func (s *joinedHostsStatements) deleteJoinedHosts(
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *joinedHostsStatements) selectJoinedHosts(
|
func (s *joinedHostsStatements) selectJoinedHostsWithTx(
|
||||||
ctx context.Context, txn *sql.Tx, roomID string,
|
ctx context.Context, txn *sql.Tx, roomID string,
|
||||||
) ([]types.JoinedHost, error) {
|
) ([]types.JoinedHost, error) {
|
||||||
stmt := common.TxStmt(txn, s.selectJoinedHostsStmt)
|
stmt := common.TxStmt(txn, s.selectJoinedHostsStmt)
|
||||||
|
return joinedHostsFromStmt(ctx, stmt, roomID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *joinedHostsStatements) selectJoinedHosts(
|
||||||
|
ctx context.Context, roomID string,
|
||||||
|
) ([]types.JoinedHost, error) {
|
||||||
|
return joinedHostsFromStmt(ctx, s.selectJoinedHostsStmt, roomID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func joinedHostsFromStmt(
|
||||||
|
ctx context.Context, stmt *sql.Stmt, roomID string,
|
||||||
|
) ([]types.JoinedHost, error) {
|
||||||
rows, err := stmt.QueryContext(ctx, roomID)
|
rows, err := stmt.QueryContext(ctx, roomID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -118,5 +130,6 @@ func (s *joinedHostsStatements) selectJoinedHosts(
|
||||||
ServerName: gomatrixserverlib.ServerName(serverName),
|
ServerName: gomatrixserverlib.ServerName(serverName),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ func (d *Database) UpdateRoom(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
joinedHosts, err = d.selectJoinedHosts(ctx, txn, roomID)
|
joinedHosts, err = d.selectJoinedHostsWithTx(ctx, txn, roomID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -110,3 +110,12 @@ func (d *Database) UpdateRoom(
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetJoinedHosts returns the currently joined hosts for room,
|
||||||
|
// as known to federationserver.
|
||||||
|
// Returns an error if something goes wrong.
|
||||||
|
func (d *Database) GetJoinedHosts(
|
||||||
|
ctx context.Context, roomID string,
|
||||||
|
) ([]types.JoinedHost, error) {
|
||||||
|
return d.selectJoinedHosts(ctx, roomID)
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue