Better link previews for private instances#41843
Conversation
… bots (Slackbot).
pjlast
left a comment
There was a problem hiding this comment.
Think this would look nice (if it works)
Maybe give it a shot 🤷
| title := path | ||
| if formattedLineRange != "" { | ||
| title += "?" + formattedLineRange | ||
| } |
There was a problem hiding this comment.
I think, instead of adding this line range to the title, add it to the card as a label. See other comments
unknwon
left a comment
There was a problem hiding this comment.
Nice! (assuming it works 😁 )
|
@novoselrok does this affect our current link expansion at all? For example if I paste a sourcegraph.com link in Slack it looks like this: |
It does not. The current link expansion only works for the .com instance. And this PR is only enabled for non-.com instances, so they should be mutually exclusive. |
camdencheek
left a comment
There was a problem hiding this comment.
LGTM! Lemme know if you run into any issues -- global feature flags are not super well exercised (but they should hopefully work just fine)

Introduces a new
OpenGraphMetadataMiddlewarethat serves a separate template with OpenGraph metadata meant for unauthenticated requests to private instances from social bots (e.g. Slackbot). Instead of redirecting the bots to the sign-in page, they can parse the OpenGraph metadata and produce a nicer link preview for a subset of Sourcegraph app routes.OpenGraphMetadataMiddlewaredoes not access any private data on the instance, it purely extracts the data already available in the URL and presents it in a nicer manner.Screenshot:
(Ignore the long ugly ngrok URL, imagine
sourcegraph.sourcegraph.cominstead 🙂)Test plan
ngrok http --host-header=rewrite 3080to expose your instance to the worldhttps://c70e-2a00-ee2-4e06-b400-820-34aa-bcc3-1523.eu.ngrok.io) and copy a repo/blob/search URL