aboutsummaryrefslogtreecommitdiff
path: root/roomserver/internal
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2022-11-14 13:07:13 +0100
committerGitHub <noreply@github.com>2022-11-14 12:07:13 +0000
commit2a77a910eb16333e56b85a7fdb3d6254acc9b6d7 (patch)
tree4ab51d00a991efec78dbb92636164ef47d39bf76 /roomserver/internal
parent858a4af2244986356576b1cf97572275a8bc001f (diff)
Handle remote room upgrades (#2866)
Makes the following tests pass ``` /upgrade moves remote aliases to the new room Local and remote users' homeservers remove a room from their public directory on upgrade ```
Diffstat (limited to 'roomserver/internal')
-rw-r--r--roomserver/internal/input/input_events.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/roomserver/internal/input/input_events.go b/roomserver/internal/input/input_events.go
index 60160e8e..682aa2b1 100644
--- a/roomserver/internal/input/input_events.go
+++ b/roomserver/internal/input/input_events.go
@@ -23,6 +23,8 @@ import (
"fmt"
"time"
+ "github.com/tidwall/gjson"
+
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/util"
"github.com/opentracing/opentracing-go"
@@ -409,6 +411,13 @@ func (r *Inputer) processRoomEvent(
}
}
+ // Handle remote room upgrades, e.g. remove published room
+ if event.Type() == "m.room.tombstone" && event.StateKeyEquals("") && !r.Cfg.Matrix.IsLocalServerName(senderDomain) {
+ if err = r.handleRemoteRoomUpgrade(ctx, event); err != nil {
+ return fmt.Errorf("failed to handle remote room upgrade: %w", err)
+ }
+ }
+
// processing this event resulted in an event (which may not be the one we're processing)
// being redacted. We are guaranteed to have both sides (the redaction/redacted event),
// so notify downstream components to redact this event - they should have it if they've
@@ -434,6 +443,13 @@ func (r *Inputer) processRoomEvent(
return nil
}
+// handleRemoteRoomUpgrade updates published rooms and room aliases
+func (r *Inputer) handleRemoteRoomUpgrade(ctx context.Context, event *gomatrixserverlib.Event) error {
+ oldRoomID := event.RoomID()
+ newRoomID := gjson.GetBytes(event.Content(), "replacement_room").Str
+ return r.DB.UpgradeRoom(ctx, oldRoomID, newRoomID, event.Sender())
+}
+
// processStateBefore works out what the state is before the event and
// then checks the event auths against the state at the time. It also
// tries to determine what the history visibility was of the event at