feat(slack): unfurl page links as the poster

Merged
SA
2mo ago
+484-32

Why

The Superset Slack app registers app.superset.sh in unfurl_domains, so Slack suppresses its own OpenGraph preview for every link on that domain and sends the app link_shared instead. The handler only recognised /tasks/<slug>; page links were logged and dropped (confirmed in prod logs for team T09Q9C3Q41Y). That is why neither org pages nor public pages unfurl in Slack today, regardless of the og tags the web app serves.

What

  • @superset/trpc/page-preview: pagePreview({ slug, organizationId, userId? }) resolves what a link may show outside the app. Public pages preview for anyone; org pages need the poster's linked Superset user and org membership; just_me pages need the creator. Anything else is missing, never the title. The thumbnail URL carries a version-bound ticket so org pages work without opening the usercontent origin.
  • page-work-object: a slack#/entities/content_item Work Object with preview image, description, created_by and date_updated.
  • process-link-shared: unfurlLinks() handles tasks and pages in one pass. An unlinked poster who shares a non-public page gets Slack's user_auth_required prompt pointing at the existing connect URL, which now carries { channel, ts, url }; the link route unfurls that message right after upsertIdentity.
  • Home tab copy mentions page links.

Verification

  • bun run typecheck in apps/api and packages/trpc: clean.
  • bun test for the Slack handlers plus the new preview.test.ts and page-work-object.test.ts: 129 pass.
  • Not yet verified in Slack: Slack posts events to the production API, so this needs a deploy. Two things to watch on the first real unfurl: whether the content_item preview image renders, and whether Slack accepts unfurls: {} alongside user_auth_required. If the image does not render, the fallback is a legacy unfurls blocks payload with an image block.

Summary by cubic

Pages shared in Slack now unfurl with a preview instead of being dropped. Previously the link_shared handler only recognized task links and logged page links away, which is why even public pages showed as bare URLs. Pages now render as a slack#/entities/content_item work object with the captured thumbnail, description, creator, and last update.

New Features

  • Preview access is per poster: public pages unfurl for anyone, org pages for organization members, and just_me pages for their creator; everything else stays missing.
  • Unlinked posters sharing a non-public page get Slack's account-connect prompt; the connect URL now carries { channel, ts, url } so the link route unfurls that message right after linking.
  • Page thumbnail URLs carry a version-bound ticket so org pages render without opening the usercontent origin.

Summary by CodeRabbit

  • New Features
    • Slack now previews shared Superset page links alongside task links, with page details shown when the viewer has access.
    • When a page requires sign-in, Slack provides a connection link and displays its preview after the account is linked.
  • Improvements
    • Updated Slack’s Getting Started guidance to mention both Superset task and page links.