Skip to content
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

Merged
merged 10 commits into from
Oct 5, 2016
Merged

Conversation

dbkr
Copy link
Member

@dbkr dbkr commented Sep 29, 2016

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

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
@dbkr
Copy link
Member Author

dbkr commented Sep 29, 2016

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) {
Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(done)

Copy link
Member

@richvdh richvdh left a 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') {
Copy link
Member

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?

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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) => {
Copy link
Member

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(done)

@richvdh richvdh assigned dbkr and unassigned richvdh Sep 30, 2016
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.
@dbkr
Copy link
Member Author

dbkr commented Oct 3, 2016

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.

@dbkr dbkr assigned richvdh and unassigned dbkr Oct 3, 2016
"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": {
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

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 } ;
Copy link
Member

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

Copy link
Member

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') {
Copy link
Member

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) {
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

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];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the_instance

Copy link
Member Author

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.

Copy link
Member

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]

Copy link
Member Author

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} />;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no width/height here?

Copy link
Member Author

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]) {
Copy link
Member

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?

Copy link
Member

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"
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

@richvdh richvdh assigned dbkr and unassigned richvdh Oct 3, 2016
@dbkr dbkr assigned richvdh and unassigned dbkr Oct 4, 2016
@richvdh richvdh assigned dbkr and unassigned richvdh Oct 4, 2016
@dbkr dbkr assigned richvdh and unassigned dbkr Oct 4, 2016
Copy link
Member

@richvdh richvdh left a 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protocolss

@richvdh richvdh removed their assignment Oct 4, 2016
@dbkr dbkr merged commit ea38968 into develop Oct 5, 2016
@t3chguy t3chguy deleted the dbkr/join_3p_location branch May 12, 2022 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants