Skip to content

Link Reconstruction#118

Merged
prajwalbang merged 6 commits into
masterfrom
deep-link-reconstruction
Jun 10, 2026
Merged

Link Reconstruction#118
prajwalbang merged 6 commits into
masterfrom
deep-link-reconstruction

Conversation

@prajwalbang

@prajwalbang prajwalbang commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

What I tried doing

RescueGroups gives us an org-level adoption URL or website URL, but not a direct animal page. For a few verified shelters, we can reconstruct the direct pet URL from IDs already present in the RescueGroups API response.

What changed

  • Added adoption_sources/pet_links.py

    • Centralizes deep-link reconstruction logic.
    • Supports verified URL patterns for:
      • sterlingshelter.org
      • smalldogrescuene.org
      • mspca.org
    • Leaves unknown/unsupported shelter domains alone.
  • Updated adoption_sources/rescue_groups.py

    • Collects possible URL candidates from the animal and org records.
    • Tries to reconstruct a pet-specific adoption URL for supported shelters.
    • Falls back to the normal RescueGroups/API URL behavior when no supported pattern matches.
    • Reads RescueGroups rescueId, which MSPCA needs for its pet URLs.
  • Updated abstractions.py

    • Added rescue_id to AdoptablePet so shelter-specific animal IDs can be carried through parsing.

Why this matters

The social posts become more useful because users can click directly to the animal they saw, instead of landing on a general adoption/search page and having to find the pet manually.

Fallback behavior

If a pet comes from a shelter we have not verified, the code does not invent a URL. It keeps the existing default URL from the API.

prajwalbang and others added 6 commits June 2, 2026 20:55
Sterling and SmallDog embed the RescueGroups toolkit, so an individual pet's
page is reachable via #action_0=pet&animalID_0=<id>, where the id is exactly
the RescueGroups animal id we already store as pet_id. Add a domain->template
registry (adoption_sources/pet_links.py) and apply it in SourceRescueGroups so
those pets link straight to the animal instead of the org landing page.

Includes unit tests and a manual verification workflow/script that finds a
supported-shelter pet from the live API and posts it to the Bluesky test account.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The repo has no BLUESKY_TEST_* secrets; use the live BLUESKY_HANDLE/PASSWORD
(authorized). Gate the live post behind a [verify-post] commit marker so routine
pushes to this branch don't publish.

[verify-post]

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Lets us target specific shelter domains (deep-linkable or not) to see their
posts live. MSPCA will show a non-pet-specific fallback link, as expected.

[verify-post]

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The RescueGroups toolkit needs the standalone sentinel petIndex_0=-1 or it can
show the full list instead of the specific animal (SmallDog link was landing on
the list). Apply to both rgtools shelters and update tests.

Also add an --inspect mode to dump the full raw API record for a shelter domain,
to check whether MSPCA's internal a##### id is exposed anywhere (it determines
whether MSPCA deep links are even possible).

[verify-post]

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
MSPCA's pet pages are /pets/<rescueId lowercased>/ (e.g. a467410), and the API
exposes that id as the 'rescueId' attribute. Generalize the registry to map each
domain to (template, id_key) so toolkit shelters use the RescueGroups pet_id and
MSPCA uses rescue_id. Capture rescueId on AdoptablePet and pass it through.

[verify-post]

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Deep-link reconstruction is validated live for Sterling, SmallDog, and MSPCA.
Ship only the source change + unit tests; drop the manual verify tooling.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@prajwalbang prajwalbang changed the title Deep link reconstruction Link Reconstruction Jun 10, 2026
@prajwalbang prajwalbang merged commit bd72fe0 into master Jun 10, 2026
2 checks passed
@prajwalbang prajwalbang deleted the deep-link-reconstruction branch June 10, 2026 00:35
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.

2 participants