aboutsummaryrefslogtreecommitdiff
path: root/federationsender/storage/shared
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2020-10-22 10:39:16 +0100
committerGitHub <noreply@github.com>2020-10-22 10:39:16 +0100
commit3afc623098dc2cc24093466f69e1d9c4bac9d35b (patch)
tree401f20e9ab2c47a1caef5e295f374118ecfcb7d3 /federationsender/storage/shared
parent04dc019e5e2f60cd387699bb7f4f7eead15ba714 (diff)
Fix RewritesState bug (#1557)
* Set RewritesState once * Check if any new state provided * Obey rewritesState * Don't nuke everything the sync API knows when purging state * Fix panic from duplicate insert * Consistency * Use HasState * Remove nolint * Clean up joined rooms on state rewrite
Diffstat (limited to 'federationsender/storage/shared')
-rw-r--r--federationsender/storage/shared/storage.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/federationsender/storage/shared/storage.go b/federationsender/storage/shared/storage.go
index 4c80c079..d5731f31 100644
--- a/federationsender/storage/shared/storage.go
+++ b/federationsender/storage/shared/storage.go
@@ -148,6 +148,20 @@ func (d *Database) StoreJSON(
}, nil
}
+func (d *Database) PurgeRoomState(
+ ctx context.Context, roomID string,
+) error {
+ return d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
+ // If the event is a create event then we'll delete all of the existing
+ // data for the room. The only reason that a create event would be replayed
+ // to us in this way is if we're about to receive the entire room state.
+ if err := d.FederationSenderJoinedHosts.DeleteJoinedHostsForRoom(ctx, txn, roomID); err != nil {
+ return fmt.Errorf("d.FederationSenderJoinedHosts.DeleteJoinedHosts: %w", err)
+ }
+ return nil
+ })
+}
+
func (d *Database) AddServerToBlacklist(serverName gomatrixserverlib.ServerName) error {
return d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
return d.FederationSenderBlacklist.InsertBlacklist(context.TODO(), txn, serverName)