-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use AS-specific room publication API #306
Changes from 12 commits
6f6fab9
4eae977
9bd881f
ff9d715
f61e08d
f756a45
0850c40
6943267
94ee49f
5a095ca
c9dedb4
7b98683
7bdd62c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,10 +20,10 @@ function PublicitySyncer(ircBridge) { | |
// should be resolved by keeping the matrix side as private as necessary | ||
this._visibilityMap = { | ||
mappings: { | ||
//room_id: ['server #channel1', 'server channel2',...] | ||
//room_id: ['funNetwork #channel1', 'funNetwork channel2',...] | ||
}, | ||
channelIsSecret: { | ||
// '$server $channel': true | false | ||
// '$networkId $channel': true | false | ||
}, | ||
roomVisibilities: { | ||
// room_id: "private" | "public" | ||
|
@@ -61,6 +61,22 @@ PublicitySyncer.prototype.initModes = Promise.coroutine(function*(server) { | |
}); | ||
}); | ||
|
||
/** | ||
* Returns the key used when calling `updateVisibilityMap` for updating an IRC channel | ||
* visibility mode (+s or -s). | ||
* ``` | ||
* // Set channel on server to be +s | ||
* const key = publicitySyncer.getIRCVisMapKey(server.getNetworkId(), channel); | ||
* publicitySyncer.updateVisibilityMap(true, key, true); | ||
* ``` | ||
* @param {string} networkId | ||
* @param {string} channel | ||
* @returns {string} | ||
*/ | ||
PublicitySyncer.prototype.getIRCVisMapKey = function(networkId, channel) { | ||
return networkId + ' ' + channel; | ||
} | ||
|
||
// This is used so that any updates to the visibility map will cause the syncer to | ||
// reset a timer and begin counting down again to the eventual call to solve any | ||
// inconsistencies in the visibility map. | ||
|
@@ -125,7 +141,7 @@ PublicitySyncer.prototype._solveVisibility = Promise.coroutine(function*() { | |
|
||
roomIds.forEach((roomId) => { | ||
this._visibilityMap.mappings[roomId] = mappings[roomId].map((mapping) => { | ||
return mapping.domain + ' ' + mapping.channel | ||
return getIRCVisMapKey(mapping.networkId, mapping.channel); | ||
}); | ||
}); | ||
|
||
|
@@ -181,8 +197,12 @@ PublicitySyncer.prototype._solveVisibility = Promise.coroutine(function*() { | |
let currentState = this._visibilityMap.roomVisibilities[roomId]; | ||
let correctState = shouldBePrivate(roomId, []) ? 'private' : 'public'; | ||
|
||
// Use the server network ID of the first mapping | ||
// 'funNetwork #channel1' => 'funNetwork' | ||
const networkId = this._visibilityMap.mappings[roomId][0].split(' ')[0]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, ignoring the null guard issue, will there always be a mapped channel for this room ID? Now that I think is no, which would then NPE on this line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The null guard shouldn't be needed, you're right (it didn't originate for any particular reason, I checked in it's blame history). And yes the mappings are guaranteed to be set for a room, and contain at least one channel mapping otherwise that room wouldn't be in the But I'd be happy to null guard just in case. |
||
|
||
if (currentState !== correctState) { | ||
return cli.setRoomDirectoryVisibility(roomId, correctState).then( | ||
return cli.setRoomDirectoryVisibilityAppService(networkId, roomId, correctState).then( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does this work for the existing Freenode rooms on matrix.org which are not in a networked list? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Much in the same way it would work for those not in the main list. |
||
() => { | ||
// Update cache | ||
this._visibilityMap.roomVisibilities[roomId] = correctState; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,15 @@ IrcServer.prototype.getReadableName = function() { | |
return ''; | ||
} | ||
|
||
/** | ||
* Returns the network ID of this server, which should be unique across all | ||
* IrcServers on the bridge. Defaults to the domain of this IrcServer. | ||
* @return {string} this.config.networkId || this.domain | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. JSDoc please. |
||
IrcServer.prototype.getNetworkId = function() { | ||
return this.config.networkId || this.domain; | ||
} | ||
|
||
/** | ||
* Returns whether the server is configured to wait getQuitDebounceDelayMs before | ||
* parting a user that has disconnected due to a net-split. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You forgot a
this.