Skip to content

Commit eb46bb2

Browse files
committed
chore: remove rollback mechanism from createRoom
1 parent 155122d commit eb46bb2

File tree

1 file changed

+1
-21
lines changed

1 file changed

+1
-21
lines changed

ee/packages/federation-matrix/src/FederationMatrix.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -233,23 +233,15 @@ export class FederationMatrix extends ServiceClass implements IFederationMatrixS
233233
throw new Error('Room is not a public or private room');
234234
}
235235

236-
let matrixRoomCreated = false;
237-
let matrixRoomResult: { room_id: string; event_id: string } | undefined;
238-
239236
try {
240237
const matrixUserId = userIdSchema.parse(`@${owner.username}:${this.serverName}`);
241238
const roomName = room.name || room.fname || 'Untitled Room';
242239

243-
// canonical alias computed from name
244-
matrixRoomResult = await federationSDK.createRoom(matrixUserId, roomName, room.t === 'c' ? 'public' : 'invite');
245-
matrixRoomCreated = true;
246-
247-
this.logger.debug('Matrix room created:', matrixRoomResult);
240+
const matrixRoomResult = await federationSDK.createRoom(matrixUserId, roomName, room.t === 'c' ? 'public' : 'invite');
248241

249242
await Rooms.setAsFederated(room._id, { mrid: matrixRoomResult.room_id, origin: this.serverName });
250243

251244
const federatedRoom = await Rooms.findOneById(room._id);
252-
253245
if (federatedRoom && isRoomNativeFederated(federatedRoom)) {
254246
await this.inviteUsersToRoom(
255247
federatedRoom,
@@ -263,18 +255,6 @@ export class FederationMatrix extends ServiceClass implements IFederationMatrixS
263255
return matrixRoomResult;
264256
} catch (error) {
265257
this.logger.error('Failed to create room:', error);
266-
267-
// if Matrix room was created but invitation failed, we should rollback the room creation
268-
if (matrixRoomCreated && matrixRoomResult) {
269-
this.logger.warn('Matrix room was created but setup failed, leaving room', matrixRoomResult.room_id);
270-
try {
271-
const matrixUserId = userIdSchema.parse(`@${owner.username}:${this.serverName}`);
272-
await federationSDK.leaveRoom(matrixRoomResult.room_id, matrixUserId);
273-
} catch (cleanupError) {
274-
this.logger.error('Failed to cleanup Matrix room after error:', cleanupError);
275-
}
276-
}
277-
278258
throw error;
279259
}
280260
}

0 commit comments

Comments
 (0)