-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add native joining of 3p networks to room dir #2379
Conversation
Use the 3rd party location lookup API to accept third-party locations in their native form and look up the corresponding portal room for that location. Also give the network dropdown some placeholder text. Fixes #2374
Tests failing because of js-sdk requirement |
this.nativePatterns = {}; | ||
if (this.props.config.networks) { | ||
for (const network of Object.keys(this.props.config.networks)) { | ||
if (this.props.config.networks[network].portalRoomPattern) { |
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.
y'know, local variables aren't rationed.
const net = this.props.config.networks[network];
// etc
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.
(done)
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.
I'm not a fan of this, for reasons discussed in #matrix-core:
- It puts knowledge that ought to be in the server in the client (specifically the
roomDirectory
object in the config). - It hardcodes a list of supported protocols into the client.
- It doesn't allow for anyone who isn't on the matrix.org HS to use the bridge functionality - which is an important feature and might change the way all this works.
Most of this, AIUI, is due to Vector making the best of the API as it stands. If it's hard for Vector to use right, then the API probably needs fixing, rather than working around.
this.showRoomAlias(alias); | ||
// If we're on the 'Matrix' network (or all networks), | ||
// just show that rooms alias | ||
if (this.state.network == null || this.state.network == '_matrix') { |
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.
how can we be sure that we don't need to do the 3rd party dance if we are showing all networks?
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.
how can we be sure that we don't need to do the 3rd party dance if we are showing all networks?
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.
If we're showing all networks, the user input is just treated as a matrix room ID: we don't do 3rd party network stuff since there'd be no obvious 3rd party network to choose.
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.
ack
|
||
_getFieldsForThirdPartyLocation: function(user_input, network) { | ||
const getfields_funcs = { | ||
irc: (user_input, network) => { |
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.
really? we're hard-coding this into vector?
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.
(done)
Try to match protocol insance from 'domain' field and use its fields for all but the last field. Assume the last takes the user input.
I've updated this to get the fields by filling in all but the last field from the instance fields and the last from the user input instead of vector explicitly supporting individual protocols. |
"irc:freenode": "//matrix.org/_matrix/media/v1/download/matrix.org/DHLHpDDgWNNejFmrewvwEAHX", | ||
"irc:mozilla": "//matrix.org/_matrix/media/v1/download/matrix.org/DHLHpDDgWNNejFmrewvwEAHX", | ||
"gitter": "//gitter.im/favicon.ico" | ||
"networks": { |
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.
if we're doing this, it needs some user documentation. What do the different fields mean? which ones are required and which optional?
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.
Yeah. Unsure what the best way to do this is, given the config file is JSON.
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.
a section in the README, maybe?
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.
Works for me
@@ -107,10 +126,10 @@ module.exports = React.createClass({ | |||
opts.server = my_server; | |||
} | |||
if (this.nextBatch) opts.since = this.nextBatch; | |||
if (this.filterString) opts.filter = { generic_search_term: my_filter_string } ; | |||
if (this.state.filterString) opts.filter = { generic_search_term: my_filter_string } ; |
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.
s/this.state.filterString
/my_filter_string
/ for clarity here
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.
(done)
this.showRoomAlias(alias); | ||
// If we're on the 'Matrix' network (or all networks), | ||
// just show that rooms alias | ||
if (this.state.network == null || this.state.network == '_matrix') { |
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.
how can we be sure that we don't need to do the 3rd party dance if we are showing all networks?
// If there's only one instance in this protocol, use it | ||
// as long as it has no domain (which we assume to mean it's | ||
// there is only one possible instance). | ||
if (the_instance.fields.domain === undefined && network_info.domain === undefined) { |
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.
I'm not sure what domain
is, but shouldn't this work if the domains are defined and match?
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.
Yeah, that would just drop into the second case. I was thinking about getting rid of the two cases here and just relying on undefined === undefined catching the first one, but figured it was clearer to leave them as two.
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.
how will it drop into the second case?
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.
Ah, I guess it won't for a single domain. Fixed.
// as long as it has no domain (which we assume to mean it's | ||
// there is only one possible instance). | ||
if (the_instance.fields.domain === undefined && network_info.domain === undefined) { | ||
instance = this.protocols[network_info.protocol].instances[0]; |
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.
the_instance
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.
This one should be 'instance' as we've now found the correct alias. I've renamed the variable to make it more obvious, hopefully.
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.
I mean, use the_instance
instead of this.protocols[network_info.protocol].instances[0]
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.
Oh, I see. Done.
name = network; | ||
} | ||
if (this.props.config.networks[network].icon) { | ||
icon = <img src={this.props.config.networks[network].icon} />; |
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.
no width/height here?
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.
Fixed
@@ -170,8 +170,19 @@ export default class NetworkDropdown extends React.Component { | |||
icon = <img src="img/network-matrix.svg" width="16" height="16" />; | |||
span_class = 'mx_NetworkDropdown_menu_network'; | |||
} else { | |||
name = this.props.config.networkNames[network]; | |||
icon = <img src={this.props.config.networkIcons[network]} />; | |||
if (this.props.config.networks[network]) { |
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.
name is left undefined
if this is false? would it make more sense to throw if it is false?
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.
(done)
@@ -199,6 +210,7 @@ export default class NetworkDropdown extends React.Component { | |||
</div>; | |||
current_value = <input type="text" className="mx_NetworkDropdown_networkoption" | |||
ref={this.collectInputTextBox} onKeyUp={this.onInputKeyUp} | |||
placeholder="matrix.org" |
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.
don't get why this is?
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.
It's just used here as an example of the name of an HS: hopefully comment clarifies.
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.
ack
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.
lgtm modulo typo
1. `roomDirectory.networks`: config for each network type. Optional. | ||
1. `roomDirectory.<network_type>.name`: Human-readable name for the network. Required. | ||
1. `roomDirectory.<network_type>.protocol`: Protocol as given by the server in | ||
`/_matrix/client/unstable/thirdparty/protocolss` response. Required to be able to join |
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.
protocolss
Use the 3rd party location lookup API to accept third-party locations
in their native form and look up the corresponding portal room for
that location.
Also give the network dropdown some placeholder text.
Fixes #2374
Requires matrix-org/matrix-react-sdk#502
Requires matrix-org/matrix-js-sdk#217