Cleanup and SQLite purge support

This commit is contained in:
Till Faelligen 2022-12-22 14:58:39 +01:00
parent e7356f7e96
commit 1536a6245f
No known key found for this signature in database
GPG key ID: ACCDC9606D472758
4 changed files with 1 additions and 23 deletions

View file

@ -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
}

View file

@ -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 {

View file

@ -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")
}

View file

@ -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 {