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

feat: Link decoration for single labeled and whitelisted internal hosts. #33230

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from

Conversation

Barrylimarti
Copy link

Proposed changes (including videos or screenshots)

Links like http://server/document were not decorated in the chat even if the user whitelisted the domain name as "server".
Screenshot 2024-09-09 at 3 21 17 AM
Screenshot 2024-09-09 at 3 20 45 AM

It needed to be parsed as a link to get decorated, hence the message-parser required to be modified to adapt to this change.
I traced the point of change to be the grammar.pegjs file, specifically where the domain was verified and then the text was passed to autolink function to get parsed as a 'LINK' and not as a 'PLAIN_TEXT'.
Screenshot 2024-09-09 at 3 14 34 AM

I created a utility function to verify the domain names from the custom whitelist for which the text needed to be parsed as a link and then used that function in the pegjs file to verify the domain name. To check this behaviour, I created a test case also.
Screenshot 2024-09-09 at 3 21 23 AM

Issue(s)

This PR may close #29874

Steps to test or reproduce

Mentioned in the issue tagged above.

Further comments

It was first time for me working on a pegjs file, hence I am not sure about the code quality. Please feel free to reach out if any changes or modification is required.

This update will capture something like http://server/document as a link
function validates custom domain names and allows them to be parsed as link even if they are single label
Copy link
Contributor

dionisio-bot bot commented Sep 8, 2024

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

Copy link

changeset-bot bot commented Sep 8, 2024

🦋 Changeset detected

Latest commit: b309d56

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 34 packages
Name Type
@rocket.chat/message-parser Minor
@rocket.chat/meteor Patch
@rocket.chat/core-services Patch
@rocket.chat/core-typings Patch
@rocket.chat/gazzodown Major
@rocket.chat/livechat Patch
@rocket.chat/rest-typings Patch
rocketchat-services Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/network-broker Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/presence Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/freeswitch Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/license Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/models Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/instance-status Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Barrylimarti Barrylimarti changed the title feat : Added link decoration for single labeled internal host which are whitelisted. feat: Added link decoration for single labeled internal host which are whitelisted. Sep 8, 2024
@Barrylimarti
Copy link
Author

I don't know if this PR requires a changeset.
Please let me know if this is needed as it is a change in the message parser package.

@casalsgh casalsgh requested a review from tassoevan September 16, 2024 12:27
Copy link
Contributor

@rique223 rique223 left a comment

Choose a reason for hiding this comment

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

I don't know if this PR requires a changeset. Please let me know if this is needed as it is a change in the message parser package.

Hey Barrylimarti, first of all thank you so much for your PR. Yes, this PR is adding features to our existing systems so a changeset is necessary. Please refer to our documentation on development workflow, at the end of it there is a nice guideline on how to write changesets: https://developer.rocket.chat/docs/development-workflow

@rique223
Copy link
Contributor

I don't know if this PR requires a changeset. Please let me know if this is needed as it is a change in the message parser package.

Hey Barrylimarti, first of all thank you so much for your PR. Yes, this PR is adding features to our existing systems so a changeset is necessary. Please refer to our documentation on development workflow, at the end of it there is a nice guideline on how to write changesets: https://developer.rocket.chat/docs/development-workflow

Also please have a look at our PR title guidelines: https://developer.rocket.chat/v1/docs/pull-requests-tags

@Barrylimarti Barrylimarti changed the title feat: Added link decoration for single labeled internal host which are whitelisted. feat: Link decoration for single labeled and whitelisted internal hosts. Sep 18, 2024
packages/message-parser/src/utils.ts Outdated Show resolved Hide resolved
Barrylimarti and others added 2 commits September 18, 2024 20:50
rique223
rique223 previously approved these changes Sep 18, 2024
tassoevan
tassoevan previously approved these changes Sep 19, 2024
@Barrylimarti Barrylimarti dismissed stale reviews from tassoevan and rique223 via dd0d96c September 19, 2024 17:56
@Barrylimarti
Copy link
Author

Hi @tassoevan Thanks for approving the PR, although I saw there was one more linting error which was failing some cases. I committed the change after fixing it now. You can check it now.

@Barrylimarti
Copy link
Author

Barrylimarti commented Sep 21, 2024

Hey guys, I can see some of the checks failing in CI. Does this mean some test cases are not passing and Can you help me how to deal with these?

@Barrylimarti
Copy link
Author

Hi @tassoevan Can you please review this again, as I checked everything on my system and the linting checks and test cases pass perfectly. It would be great motivation for me if this PR gets merged.

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.

Link decoration doesn't work with single word domain names
4 participants