message: Leaves are now behind some queues to avoid spam
diff: @@ -22,6 +22,7 @@ const MODES_TO_WATCH = [
  ];
  const NICK_USERID_CACHE_MAX = 512;
  +const LEAVE_CONCURRENCY = 10;
  function IrcHandler(ircBridge, config) {
  config = config || {}
  @@ -57,6 +58,25 @@ function IrcHandler(ircBridge, config) {
  // Map<string,bool> which contains nicks we know have been registered/has display name
  this._registeredNicks = Object.create(null);
  +
  + // QueuePool for leaving "concurrently" without slowing leaves to a crawl.
  + // Takes {rooms, matrixUser}
  + this._leaveQueue = new QueuePool(
  + config.leaveConcurrency || LEAVE_CONCURRENCY,
  + (item) => {
  + return Promise.all(item.rooms.map((room) => {
  + req.log.info(
  + "Leaving room %s (%s)",
  + room.getId(),
  + item.matrixUser.getId()
  + );
  + return this.ircBridge.getAppServiceBridge().getIntent(
  + item.matrixUser.getId()
  + ).leave(room.getId());
  + }));
  + }
  + );
  +
  this.getMetrics();
  }
  @@ -733,14 +753,12 @@ IrcHandler.prototype.onPart = Promise.coroutine(function*(req, server, leavingUs
  }
  }
  - let promises = matrixRooms.map((room) => {
  - req.log.info("Leaving room %s", room.getId());
  - return this.ircBridge.getAppServiceBridge().getIntent(
  - matrixUser.getId()
  - ).leave(room.getId());
  - });
  + const promise = this._leaveQueue.enqueue(chan+leavingUser.nick, {
  + rooms: matrixRooms,
  + matrixUser
  + })
  stats.membership(true, "part");
  - yield Promise.all(promises);
  + yield promise;
  });
  IrcHandler.prototype.onMode = Promise.coroutine(function*(req, server, channel, by,
  