message: DataStore functions for storing mode across restarts
diff: @@ -311,6 +311,46 @@ DataStore.prototype.getMappingsForChannelByOrigin = function(server, channel, or
  });
  };
  +DataStore.prototype.getModesForChannel = function (server, channel) {
  + log.info("getModesForChannel (server=%s, channel=%s)",
  + server.domain, channel
  + );
  + let remoteId = IrcRoom.createId(server, channel);
  + return this._roomStore.getEntriesByRemoteId(remoteId).then((entries) => {
  + const mapping = {};
  + entries.forEach((entry) => {
  + mapping[entry.matrix.getId()] = entry.remote.get("modes") || [];
  + });
  + return mapping;
  + });
  +};
  +
  +DataStore.prototype.setModeForRoom = Promise.coroutine(function*(roomId, mode, remove=False) {
  + log.info("setModeForRoom (mode=%s, roomId=%s, remove=%s)",
  + mode, roomId, remove
  + );
  + this._roomStore.getEntriesByMatrixId(roomId).then((entries) => {
  + entries.forEach((entry) => {
  + const modes = entry.remote.get("modes") || [];
  + const hasMode = modes.includes(mode);
  +
  + if ((!hasMode && remove) || (hasMode && !remove)) {
  + return;
  + }
  +
  + if (remove) {
  + modes.splice(modes.indexOf(mode), 1);
  + } else {
  + modes.push(mode);
  + }
  +
  + entry.remote.set("modes", modes);
  +
  + return this._roomStore.upsertEntry(entry);
  + });
  + });
  +});
  +
  DataStore.prototype.setPmRoom = function(ircRoom, matrixRoom, userId, virtualUserId) {
  log.info("setPmRoom (id=%s, addr=%s chan=%s real=%s virt=%s)",
  matrixRoom.getId(), ircRoom.server.domain, ircRoom.channel, userId,
  