From db9ca401b04b6af88429a7bc568764ad24bb9924 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Mon, 22 Aug 2022 12:49:04 +0100 Subject: [PATCH] Wire that up --- syncapi/consumers/roomserver.go | 9 +++++++-- syncapi/storage/interface.go | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/syncapi/consumers/roomserver.go b/syncapi/consumers/roomserver.go index 891b02088..ea9a36e9a 100644 --- a/syncapi/consumers/roomserver.go +++ b/syncapi/consumers/roomserver.go @@ -440,9 +440,14 @@ func (s *OutputRoomEventConsumer) onPurgeRoom( ctx context.Context, req api.OutputPurgeRoom, ) error { logrus.WithField("room_id", req.RoomID).Warn("Purging room from sync API") - defer logrus.WithField("room_id", req.RoomID).Warn("Room purged from sync API") - return nil + if err := s.db.PurgeRoom(ctx, req.RoomID); err != nil { + logrus.WithField("room_id", req.RoomID).WithError(err).Error("Failed to purge room from sync API") + return err + } else { + logrus.WithField("room_id", req.RoomID).Warn("Room purged from sync API") + return nil + } } func (s *OutputRoomEventConsumer) updateStateEvent(event *gomatrixserverlib.HeaderedEvent) (*gomatrixserverlib.HeaderedEvent, error) { diff --git a/syncapi/storage/interface.go b/syncapi/storage/interface.go index 43a75da95..66d3af96a 100644 --- a/syncapi/storage/interface.go +++ b/syncapi/storage/interface.go @@ -75,6 +75,7 @@ type Database interface { // PurgeRoomState completely purges room state from the sync API. This is done when // receiving an output event that completely resets the state. PurgeRoomState(ctx context.Context, roomID string) error + PurgeRoom(ctx context.Context, roomID string) error // GetStateEvent returns the Matrix state event of a given type for a given room with a given state key // If no event could be found, returns nil // If there was an issue during the retrieval, returns an error