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

the base domain permalinks don't have the mxid in the first param but… #3735

Merged
merged 4 commits into from
Aug 30, 2021

Conversation

chagai95
Copy link
Contributor

… in the second after /user/mxid

Pull Request Checklist

Signed-off-by: Chagai Friedlander [email protected]

@chagai95
Copy link
Contributor Author

should solve #3454

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Thanks for the PR.
One remark, also can you add a file 3735.bugfix in the folder changelog.d describing the change please?

@@ -53,7 +53,12 @@ object PermalinkParser {
.filter { it.isNotEmpty() }
.take(2)

val identifier = params.getOrNull(0)
// the base domain permalinks don't have the mxid in the first param but in the second after /user/mxid
Copy link
Member

Choose a reason for hiding this comment

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

Can you provide an example of such URL? Maybe in the doc of this method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added an example. Thx for reviewing

@chagai95
Copy link
Contributor Author

chagai95 commented Jul 28, 2021

I added the bugfix file, thanks for reviewing @bmarty

*/
fun parse(uriString: String): PermalinkData {
val uri = Uri.parse(uriString)
return parse(uri)
}

/**
* Turns an uri to a [PermalinkData]
* Turns a uri to a [PermalinkData]
*/
fun parse(uri: Uri): PermalinkData {
if (!uri.toString().startsWith(PermalinkService.MATRIX_TO_URL_BASE)) {
Copy link
Member

@bmarty bmarty Jul 29, 2021

Choose a reason for hiding this comment

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

You won't get to your change, uri has to start by https://matrix.to/#/

Copy link
Contributor Author

@chagai95 chagai95 Jul 29, 2021

Choose a reason for hiding this comment

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

I changed the MATRIX_TO_URL_BASE variable on my fork to be the element-based domain permalink, that's why for me it worked, I think this is easier to find this issue than to find a hard coded array, I could add this to a comment but it will of course be better to make a variable out of this, I don't think I can get to doing that easily but if anyone else wants to pick this PR and do it before I do, please do... I understand if you don't want to merge like this, I just wanted others to not spend a day looking for this issue 🙈 on our fork it's working now... @bmarty

Copy link
Member

Choose a reason for hiding this comment

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

Ah, we build matrix.to links, so it's OK I think...

Copy link
Contributor Author

@chagai95 chagai95 Jul 29, 2021

Choose a reason for hiding this comment

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

For you it's fine but other forks use element-based domain permalinks 😬 @bmarty

Copy link
Member

@bmarty bmarty Jul 29, 2021

Choose a reason for hiding this comment

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

Ok, thanks for the explaination. We definitely need to improve this code, and add unit test.

Also I guess you will have the same problem for room or group URL, for instance:

https://develop.element.io/#/room/#element-android:matrix.org

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep thanks, we don't have room links but thx for the heads up 😉

@@ -53,7 +55,12 @@ object PermalinkParser {
.filter { it.isNotEmpty() }
.take(2)

val identifier = params.getOrNull(0)
// the the element-based domain permalinks (e.g. https://app.element.io/#/user/@chagai95:matrix.org) don't have the mxid in the first param (like matrix.to does - https://matrix.to/#/@chagai95:matrix.org) but rather in the second after /user/ so /user/mxid
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the comment. There is a double the but it's not a big deal.

if (identifier.equals("user")) {
identifier = params.getOrNull(1)
}

val extraParameter = params.getOrNull(1)
Copy link
Member

Choose a reason for hiding this comment

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

For a domain room url then it will have to become params.getOrNull(2)

@chagai95
Copy link
Contributor Author

Do I need to do anything to pass the code quality checks? @bmarty

@bmarty
Copy link
Member

bmarty commented Aug 23, 2021

Hello @chagai95 I think c1c936e has been added to this PR by mistake?

@chagai95
Copy link
Contributor Author

Hello @chagai95 I think c1c936e has been added to this PR by mistake?

Yep, sorry I'll revert, I forgot the pr is still open, should've done it on a branch 🤦

@chagai95
Copy link
Contributor Author

So I reset to the last commit we spoke about, is there anything missing still? @bmarty

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

No, thanks for the cleanup

@bmarty bmarty enabled auto-merge August 27, 2021 15:53
@bmarty bmarty disabled auto-merge August 30, 2021 12:25
@bmarty bmarty merged commit f2c6901 into element-hq:develop Aug 30, 2021
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