Skip to content

Commit 94445d8

Browse files
committed
fix(federation-matrix): add subscription check before user leaves room to ensure valid operation
1 parent 683a6dd commit 94445d8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,12 @@ export class FederationMatrix extends ServiceClass implements IFederationMatrixS
756756
return;
757757
}
758758

759+
const subscription = await Subscriptions.findOne({ 'rid': room._id, 'u._id': user._id });
760+
if (!subscription) {
761+
this.logger.debug(`User ${user.username} is not subscribed to room ${room._id}, skipping leave operation`);
762+
return;
763+
}
764+
759765
const actualMatrixUserId = isUserNativeFederated(user) ? user.federation.mui : `@${user.username}:${this.serverName}`;
760766

761767
await this.homeserverServices.room.leaveRoom(roomIdSchema.parse(room.federation.mrid), userIdSchema.parse(actualMatrixUserId));

0 commit comments

Comments
 (0)