Send the output event first
This commit is contained in:
parent
4e4fc400a2
commit
e31469682d
|
@ -246,10 +246,14 @@ func (r *Admin) PerformAdminPurgeRoom(
|
|||
return nil
|
||||
}
|
||||
|
||||
logrus.WithField("room_id", req.RoomID).Warn("Purging room from roomserver")
|
||||
defer logrus.WithField("room_id", req.RoomID).Warn("Room purged from roomserver")
|
||||
|
||||
if err := r.DB.PurgeRoom(ctx, req.RoomID); err != nil {
|
||||
if err := r.Inputer.OutputProducer.ProduceRoomEvents(req.RoomID, []api.OutputEvent{
|
||||
{
|
||||
Type: api.OutputTypePurgeRoom,
|
||||
PurgeRoom: &api.OutputPurgeRoom{
|
||||
RoomID: req.RoomID,
|
||||
},
|
||||
},
|
||||
}); err != nil {
|
||||
res.Error = &api.PerformError{
|
||||
Code: api.PerformErrorBadRequest,
|
||||
Msg: err.Error(),
|
||||
|
@ -257,12 +261,16 @@ func (r *Admin) PerformAdminPurgeRoom(
|
|||
return nil
|
||||
}
|
||||
|
||||
return r.Inputer.OutputProducer.ProduceRoomEvents(req.RoomID, []api.OutputEvent{
|
||||
{
|
||||
Type: api.OutputTypePurgeRoom,
|
||||
PurgeRoom: &api.OutputPurgeRoom{
|
||||
RoomID: req.RoomID,
|
||||
},
|
||||
},
|
||||
})
|
||||
logrus.WithField("room_id", req.RoomID).Warn("Purging room from roomserver")
|
||||
if err := r.DB.PurgeRoom(ctx, req.RoomID); err != nil {
|
||||
logrus.WithField("room_id", req.RoomID).WithError(err).Warn("Failed to purge room from roomserver")
|
||||
res.Error = &api.PerformError{
|
||||
Code: api.PerformErrorBadRequest,
|
||||
Msg: err.Error(),
|
||||
}
|
||||
} else {
|
||||
logrus.WithField("room_id", req.RoomID).Warn("Room purged from roomserver")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1361,11 +1361,7 @@ func (d *Database) PurgeRoom(ctx context.Context, roomID string) error {
|
|||
}
|
||||
return d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
|
||||
roomNID, err := d.RoomsTable.SelectRoomNID(ctx, txn, roomID)
|
||||
switch err {
|
||||
case sql.ErrNoRows:
|
||||
return nil // return nil anyway so we can generate output event for other components
|
||||
case nil:
|
||||
default:
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to find room NID: %w", err)
|
||||
}
|
||||
if err := d.Purge.PurgeStateBlocks(ctx, txn, roomNID); err != nil {
|
||||
|
|
Loading…
Reference in a new issue