Repository navigation
fix: preview Jira issues whose project key contains digits - #241
Merged
Merged
Conversation
Jira Cloud project keys are a letter followed by letters or digits, but the link preview only recognised keys made of letters, so a link such as https://example.atlassian.net/browse/AB12C-345 got a generic link card. The preview now also looks an issue up on the site the link points to, and only when the user is connected to that site: for an API token or a login and password, the host the user connected to or the host of the base URL kept from Jira; for OAuth, one of the authorised sites. It used to look the key up on the user's own Jira whatever the link's host, so a link to another company's site showed the user's own issue with the same key, and a user who authorised several sites with OAuth got the generic link card unless every site had an issue with that key, and then saw the last site's one. Connecting with an API token or a login and password now asks Jira for its base URL, which names the site when the connection goes through Atlassian's API gateway, and keeps it in place of any kept before. A gateway connection made before this change shows its link previews again once it is connected again. An issue that cannot be shown, such as one the user cannot see, now gets the generic link card without two PHP warnings in the log. Fixes #236 Signed-off-by: Oleksander Piskun <oleksandr2088@icloud.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #236
Project keys with digits got a generic link card
Jira Cloud project keys are a letter followed by letters or digits, such as
AB12C. The link preview recognised only keys made of letters, so the app turned down a link likehttps://example.atlassian.net/browse/AB12C-345, and apps such as Whiteboard and Talk showed it as a generic link card. A project key is now a letter followed by one or more letters, digits or underscores, in any case. The link has to start with the issue page, and it can go on with a path, a query, a fragment or the punctuation of the sentence it ends.A link is looked up on the site it points to
The preview looked the key up on the user's own Jira whatever host the link named, so a link to another company's site showed the user's own issue with the same key. With OAuth it asked the authorised sites in turn and stopped at the first one without that issue, so the preview only worked when every site had an issue with that key, and then showed the last site's one. The preview is now offered only for a site the user is connected to, and the issue is asked from that site alone. For an API token or a login and password, that is the host the user connected to or the host of the base URL kept from Jira; for OAuth, one of the authorised sites. Deciding this takes no request to Jira.
Connecting asks Jira for its base URL
Connecting with an API token or a login and password now also asks Jira for the base URL it builds its links with (
rest/api/2/serverInfo), and keeps it in place of any kept before. A connection through Atlassian's API gateway (https://api.atlassian.com/ex/jira/…) needs it to recognise its own site's links, so a gateway connection made before this change shows its link previews again once it is connected again. When Jira gives no usable answer, only the host the user connected to counts until a base URL is known, as the avatars still ask for it too.An issue that cannot be shown falls back without warnings
An issue the preview could not show, such as one the user cannot see, reached the generic link card only after two PHP warnings and a type error, and the warnings went to the log. It now falls back directly.
🤖 AI (if applicable)