Skip to content

Commit

Permalink
Support setting a room version
Browse files Browse the repository at this point in the history
  • Loading branch information
Half-Shot committed Jun 6, 2019
1 parent 63ae70b commit ee46907
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
3 changes: 3 additions & 0 deletions config.sample.yaml
Expand Up @@ -182,6 +182,9 @@ ircService:
# HS attached to this AS will be able to interact with this room.
# Default: true.
federate: true
# Force this room version when creating IRC channels. Beware if the homeserver doesn't
# support the room version then the request will fail. By default, no version is requested.
# roomVersion: "1"
# The room alias template to apply when creating new aliases. This only
# applies if createAlias is 'true'. The following variables are exposed:
# $SERVER => The IRC server address (e.g. "irc.example.com")
Expand Down
26 changes: 15 additions & 11 deletions lib/bridge/MatrixHandler.js
Expand Up @@ -1523,17 +1523,21 @@ MatrixHandler.prototype._onAliasQuery = Promise.coroutine(function*(req, roomAli
}
});
}
let res = yield botIntent.createRoom({
options: {
room_alias_name: roomAlias.split(":")[0].substring(1), // localpart
name: channelInfo.channel,
visibility: "private",
preset: "public_chat",
creation_content: {
"m.federate": channelInfo.server.shouldFederate()
},
initial_state
}
const options = {
room_alias_name: roomAlias.split(":")[0].substring(1), // localpart
name: channelInfo.channel,
visibility: "private",
preset: "public_chat",
creation_content: {
"m.federate": channelInfo.server.shouldFederate()
},
initial_state
};
if (channelInfo.server.forceRoomVersion()) {
options.room_version = channelInfo.server.forceRoomVersion();
}
const res = yield botIntent.createRoom({
options,
});
newRoomId = res.room_id;
}
Expand Down
2 changes: 2 additions & 0 deletions lib/config/schema.yml
Expand Up @@ -255,6 +255,8 @@ properties:
enum: ["invite", "public"]
federate:
type: "boolean"
roomVersion:
type: "string"
aliasTemplate:
type: "string"
pattern: "^#.*\\$CHANNEL"
Expand Down
3 changes: 3 additions & 0 deletions lib/irc/IrcServer.js
Expand Up @@ -181,6 +181,9 @@ IrcServer.prototype.getMemberListFloodDelayMs = function() {
IrcServer.prototype.shouldFederate = function() {
return this.config.dynamicChannels.federate;
};
IrcServer.prototype.forceRoomVersion = function() {
return this.config.dynamicChannels.roomVersion;
};

IrcServer.prototype.getPort = function() {
return this.config.port;
Expand Down

0 comments on commit ee46907

Please sign in to comment.