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

Clickable roomId on message #1268

Merged
merged 6 commits into from
Jan 15, 2024
Merged

Clickable roomId on message #1268

merged 6 commits into from
Jan 15, 2024

Conversation

kumarpalsinh25
Copy link
Contributor

@kumarpalsinh25 kumarpalsinh25 commented Jan 11, 2024

});

test(
group(
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!!

Copy link
Contributor

@gtalha07 gtalha07 left a comment

Choose a reason for hiding this comment

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

Great and useful changes overall, there's one change I'd like to have prior to merging!!

Copy link
Contributor

@gnunicorn gnunicorn left a comment

Choose a reason for hiding this comment

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

There is another format missing, and while I can ignore the questionable way to create the via-param, we need to have support for linking to spaces, too!

Comment on lines 72 to 77
var roomIdWithServer = '$roomId:$server';

//For public groups - Replace encoded '%23' string with #
if (roomIdWithServer.startsWith('%23')) {
roomIdWithServer = roomIdWithServer.replaceAll('%23', '#');
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you just want to use the URI class and its decoder functions here ... there could be more than just the starting character being encoded...

@@ -139,9 +139,10 @@ class RoomProfilePage extends ConsumerWidget {
tiles: [
SettingsTile(
onPressed: (ctx) {
final serverName = roomId.split(':').last;
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't really how via is meant to work. See the matrix URI spec for details. But ideally via tells you about (additional) servers that we know to be in the room as alternative ways to connect to the room (in particular if the homeserver isn't available). Just repeating the homeserver is a bit of a short-cut that doesn't in practice actually help doing the right resolution.

We can keep this for now, but should probably add a helper function on the rust side that compiles the actual correct information including via.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok got it. I will check for matrix specification and do required changes accordingly.

Copy link
Contributor Author

@kumarpalsinh25 kumarpalsinh25 Jan 12, 2024

Choose a reason for hiding this comment

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

I have read the documentations, and agree with you that repeating the homeserver doesn't make sense.

I'm adding FIXME comment and once rust side helper function is ready then will change it accordingly.

Comment on lines +57 to +60
final urlRegexp = RegExp(
r'https://matrix\.to/#/(?<roomId>.+):(?<server>.+)+',
caseSensitive: false,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

matrix:// is also a valid link format: https://spec.matrix.org/v1.9/appendices/#uris

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How can I get link like matrix:// from Acter or Element general?

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure which clients are sending those at the moment... the element-x iOS maybe?

Copy link
Contributor Author

@kumarpalsinh25 kumarpalsinh25 Jan 12, 2024

Choose a reason for hiding this comment

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

@gnunicorn
No, I have check element web and element iOS. Both are sending matrix.to url.

And matrix:// is not a link url,I believe It is url schema which is generally used in deep linking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gnunicorn

  • Is there any platform or way using with I can get matrix:// and test it?
  • If matrix:// type of url are consider as url schema then still I have to handle condition for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

matrix.to is the old, matrix: is the new way of doing it.

@gnunicorn
Sorry but I'm not agree with that.

Not sure but based on the my knowledge matrix:// and matrix.to are different things and have their own purposes.

  • matrix:// is Matrix URI scheme which ideally suitable in deep-linking for direct intent calls
  • matrix.to is Matrix Navigation URL and widely used by all the matrix platforms but general navigations.

For better clarification, I'm looking for any platform which is using matrix:// (Matrix URI Scheme definition).
If you have any idea about such matrix platforms then can you please share it so that I can look into the same and get detail understanding.

And if you don't mind then can we proceed with this PR as this PR is mainly for copying RoomID URL from profile page and user should able to handle it with click on that message like element and other platforms doing because matrix:// is different thing and don't have any use-case at least in Acter App.

Copy link
Contributor

Choose a reason for hiding this comment

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

are different things and have their own purposes.

That is a misunderstanding though. Quoting the spec, about the matrix.to it says: "This namespacing existed prior to a matrix: scheme." hinting to the fact that they do the same but the existence of both is just an historically artifact to stay backwards compatible when matrix: was added: Both are used for deep-linking (clicking the matrix.to-link on a smartphone with element on it, you will see it come up), and targeting the same objects. From a purpose perspective they do and are the same. With matrix: (no double // after the :by the way) being the one for the future and matrix.to being the fallback.

Thus if want to only use one, we should do the matrix:-format and not the old one but we are only using the legacy with this PR. If you don't want to implement this now, let's open a ticket saying we need matrix:-protocol-support.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @gnunicorn for details understanding.
If matrix:// is the new way then for navigating and deep-link then I would like to integrate that way in Acter and have support for both.

@gnunicorn Do you have idea of any of the matrix platform which is using this new way? I just wanted to confirm certain use-cases with that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you have idea of any of the matrix platform which is using this new way? I just wanted to confirm certain use-cases with that.

as said, if Element-X isn't using it, I wouldn't know if any does. According to the original spec proposal fluffychat and nheko have support for it (don't know if they post use it primarily though).

FYI, when I say the "new way" of doing it ... the Spec was merged 2021 .... and looks like even Element doesn't use it primarily yet, so ....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aha, I see..
Let me create create new ticket for "matrix:-protocol-support" and then we can move on with current matrix.to support.

@@ -56,7 +61,7 @@ class _TextMessageBuilderConsumerState
//remove mx-reply tags.
String parsedString = simplifyBody(widget.message.text);
final urlRegexp = RegExp(
r'https://matrix\.to/#/@[A-Za-z0-9\-]+:[A-Za-z0-9\-]+\.[A-Za-z0-9\-]+',
r'https://matrix\.to/#/[@!#][A-Za-z0-9\-]+:[A-Za-z0-9\-]+\.[A-Za-z0-9\-]+',
Copy link
Contributor

Choose a reason for hiding this comment

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

matrix:// is also a valid link we need to check for https://spec.matrix.org/v1.9/appendices/#uris

}
}

void askToJoinGroup(
Copy link
Contributor

Choose a reason for hiding this comment

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

this should probably become a system-wide route as there are more complex scenarios we need to match, where we might a) need to knock first or load data from remotely before we even know ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understood, let me move this function to chat_utils

Comment on lines 197 to 210
final chat = await ref.read(chatProvider(roomId).future);
if (!context.mounted) return;
if (chat.isJoined()) {
// Navigate to chat room
context.goNamed(
Routes.chatroom.name,
pathParameters: {'roomId': chat.getRoomIdStr()},
);
} else {
askToJoinGroup(context, ref, roomId);
}
} catch (e) {
askToJoinGroup(context, ref, roomId);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What if the link is for a space? Then we don't properly route there?

});

test(
group(
Copy link
Contributor

Choose a reason for hiding this comment

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

👏

- Used URI class for better management of the urls
- Separated some code for making then reusable
@kumarpalsinh25 kumarpalsinh25 merged commit 0009900 into main Jan 15, 2024
25 checks passed
@kumarpalsinh25 kumarpalsinh25 deleted the kumar/issue-1097 branch January 15, 2024 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants