message: Ensure all messages are tried
diff: @@ -623,16 +623,27 @@ export class IrcHandler {
  this.registeredNicks[nickKey] = true;
  }
  - const promises = [];
  + const failed = [];
  for (const room of matrixRooms) {
  req.log.info(
  "Relaying in room %s", room.getId()
  );
  - promises.push(
  - this.ircBridge.sendMatrixAction(room, virtualMatrixUser, mxAction)
  - );
  + try {
  + await this.ircBridge.sendMatrixAction(room, virtualMatrixUser, mxAction);
  }
  - await Promise.all(promises);
  + catch (ex) {
  + // Check if it was a permission fail.
  + if (ex.data?.errcode === "M_FORBIDDEN" &&
  + ex.data?.error?.startsWith("You don't have permission to post that to the room.")) {
  + req.log.warn(`User ${virtualMatrixUser.getId()} doesn't have permission to post in ${room.getId()}`);
  + this.roomAccessSyncer.onFailedMessage(req, server, channel);
  + }
  + // Do not fail the operation because a message failed, but keep track of the failures
  + failed.push(Promise.reject(ex));
  + }
  + }
  + // We still want the request to fail
  + await Promise.all(failed);
  return undefined;
  }
  