Skip to content

Migrate the OG scrape response to the generated GetOGResponse model - #6657

Draft
gpunto wants to merge 1 commit into
developfrom
migrate/og-enrich
Draft

Migrate the OG scrape response to the generated GetOGResponse model#6657
gpunto wants to merge 1 commit into
developfrom
migrate/og-enrich

Conversation

@gpunto

@gpunto gpunto commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Goal

Migrate the OG scrape response to the generated GetOGResponse model, so enrichUrl no longer parses
into the hand-written AttachmentDto.

Part of AND-1291

Implementation

  • OpenGraphApi.get() returns the generated GetOGResponse, mapped to the domain Attachment.
  • Add GetOGResponseAdapter so root-level custom fields are still collected into extraData, which is
    what AttachmentDtoAdapter did for this endpoint.
  • Add the generated GetOGResponse, Images, ImageData, Action and Field. The last four come along
    because Go's GetOGResponse embeds the whole Attachment payload, so the schema inherits every field
    an attachment can carry, not only the ones a scrape produces.

AttachmentDto stays: message and draft attachments still use it.

Notes

GetOGResponse embeds the whole attachment shape, so it declares more than a scrape produces. The mapper
covers all of it except giphy, which is not mapped here: it has a single producer, the giphy slash
command writing to a message attachment, so it cannot reach /og. The slice that adopts the shared
Attachment model owns it, and has to re-emit it into extraData["giphy"] or Attachment.giphyInfo()
stops finding gif urls; closure.py prints that reminder for any closure containing Images.

file_size, image, mime_type and name are absent from the payload struct, so when they are sent they
arrive inside custom. The mapper reads them back out and removes them, so they do not also sit in
extraData under their wire names, which is how the hand-written DTO behaved.

E2E

/og is routed in the mock server, and it answers with a recorded message attachment that carries no
duration, the one field the generated model requires non-null. HyperLinksTests covers the unsplash and
youtube previews, so this would go red without
mock-server #64, which sends
duration on that response. Needs an E2E run with mock_server_branch:fix/og-duration before merging.

Testing

  • GetOGResponseParsingTest covers the collected custom data, an empty scrape falling back to domain
    defaults, the undeclared root fields being mapped and removed from extraData, and
    author_name/author_link, which are same-named on both sides so a swap would otherwise go unnoticed.
  • Device-probed enrichUrl against three pages (an article, an image page and a video page), logging the
    raw response body next to every field of the resulting Attachment. The wire returned type, title,
    title_link, text, image_url, thumb_url, asset_url, og_scrape_url and duration, all mapping
    correctly (duration is response metadata with no domain field), and extraData stayed empty, so
    nothing arrived under an unexpected name. The remaining declared fields were not seen on those three
    pages, which is why they are mapped rather than dropped: three samples cannot show a field is never
    sent, and losing one would be silent.

@gpunto gpunto added the pr:internal Internal changes / housekeeping label Aug 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled, or the PR is bot-authored.
  • An issue is linked (Linear ticket or GitHub issue), or the PR is bot-authored.

🎉 Great job! This PR is ready for review.

@github-actions

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 6.06 MB 6.06 MB 0.00 MB 🟢
stream-chat-android-ui-components 11.36 MB 11.37 MB 0.00 MB 🟢
stream-chat-android-compose 12.84 MB 12.84 MB 0.00 MB 🟢

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:internal Internal changes / housekeeping

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant