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