mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-18 11:33:10 -06:00
Cleanup and SQLite purge support
This commit is contained in:
parent
e7356f7e96
commit
1536a6245f
|
|
@ -71,9 +71,6 @@ const selectJoinedHostsForRoomsExcludingBlacklistedSQL = "" +
|
|||
" SELECT server_name FROM federationsender_blacklist WHERE j.server_name = server_name" +
|
||||
");"
|
||||
|
||||
const purgeJoinedHostsSQL = "" +
|
||||
"DELETE FROM federationsender_joined_hosts WHERE room_id = $1"
|
||||
|
||||
type joinedHostsStatements struct {
|
||||
db *sql.DB
|
||||
insertJoinedHostsStmt *sql.Stmt
|
||||
|
|
@ -83,7 +80,6 @@ type joinedHostsStatements struct {
|
|||
selectAllJoinedHostsStmt *sql.Stmt
|
||||
selectJoinedHostsForRoomsStmt *sql.Stmt
|
||||
selectJoinedHostsForRoomsExcludingBlacklistedStmt *sql.Stmt
|
||||
purgeJoinedHostsStmt *sql.Stmt
|
||||
}
|
||||
|
||||
func NewPostgresJoinedHostsTable(db *sql.DB) (s *joinedHostsStatements, err error) {
|
||||
|
|
@ -115,9 +111,6 @@ func NewPostgresJoinedHostsTable(db *sql.DB) (s *joinedHostsStatements, err erro
|
|||
if s.selectJoinedHostsForRoomsExcludingBlacklistedStmt, err = s.db.Prepare(selectJoinedHostsForRoomsExcludingBlacklistedSQL); err != nil {
|
||||
return
|
||||
}
|
||||
if s.purgeJoinedHostsStmt, err = s.db.Prepare(purgeJoinedHostsSQL); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -230,10 +223,3 @@ func joinedHostsFromStmt(
|
|||
|
||||
return result, rows.Err()
|
||||
}
|
||||
|
||||
func (s *joinedHostsStatements) PurgeJoinedHosts(
|
||||
ctx context.Context, txn *sql.Tx, roomID string,
|
||||
) error {
|
||||
_, err := sqlutil.TxStmt(txn, s.purgeJoinedHostsStmt).ExecContext(ctx, roomID)
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ func (d *Database) GetNotaryKeys(
|
|||
|
||||
func (d *Database) PurgeRoom(ctx context.Context, roomID string) error {
|
||||
return d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
|
||||
if err := d.FederationJoinedHosts.PurgeJoinedHosts(ctx, txn, roomID); err != nil {
|
||||
if err := d.FederationJoinedHosts.DeleteJoinedHostsForRoom(ctx, txn, roomID); err != nil {
|
||||
return fmt.Errorf("failed to purge joined hosts: %w", err)
|
||||
}
|
||||
if err := d.FederationInboundPeeks.DeleteInboundPeeks(ctx, txn, roomID); err != nil {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package sqlite3
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/matrix-org/dendrite/federationapi/types"
|
||||
|
|
@ -227,9 +226,3 @@ func joinedHostsFromStmt(
|
|||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *joinedHostsStatements) PurgeJoinedHosts(
|
||||
ctx context.Context, txn *sql.Tx, roomID string,
|
||||
) error {
|
||||
return fmt.Errorf("not implemented on SQLite")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@ type FederationJoinedHosts interface {
|
|||
SelectJoinedHosts(ctx context.Context, roomID string) ([]types.JoinedHost, error)
|
||||
SelectAllJoinedHosts(ctx context.Context) ([]gomatrixserverlib.ServerName, error)
|
||||
SelectJoinedHostsForRooms(ctx context.Context, roomIDs []string, excludingBlacklisted bool) ([]gomatrixserverlib.ServerName, error)
|
||||
PurgeJoinedHosts(ctx context.Context, txn *sql.Tx, roomID string) error
|
||||
}
|
||||
|
||||
type FederationBlacklist interface {
|
||||
|
|
|
|||
Loading…
Reference in a new issue