discourse/plugins/discourse-patreon/lib
Rafael dos Santos Silva bbc2fed22b
FIX: Patreon API pagination bugs causing missing pledges (#39058)
## Summary

- **Nil patron data crash**: Patreon V1 API can return pledge entries
where `relationships.patron.data` is null (deleted/deactivated
accounts). This caused `extract` to raise `NoMethodError`, preventing
`save!` from completing — leaving the pledge store stuck at stale data
(exactly 100 pledges from a previous sync). Fixed with `dig` for safe
nil traversal, skipping entries with missing IDs.
- **Double base URL**: Pagination `next` links from Patreon are absolute
URLs, but `Api.get` was prepending the base URL again
(`https://api.patreon.comhttps://api.patreon.com/...`). Fixed by
detecting absolute URIs and using them directly.
- **Non-incremental saves**: All pages were collected before a single
`save!`. If any page failed, nothing was persisted. Now each page is
saved incrementally — first page clears stale data, subsequent pages
append. Also handles the edge case where the API returns empty data by
explicitly clearing the store so ex-patrons don't keep group access.
2026-04-01 17:18:51 -03:00
..
api_version FIX: Patreon API pagination bugs causing missing pledges (#39058) 2026-04-01 17:18:51 -03:00
discourse_patreon DEV: Upgrade Patreon plugin to API v2 with v1 backward compatibility (#38871) 2026-03-30 14:43:34 -03:00
validators
api.rb FIX: Patreon API pagination bugs causing missing pledges (#39058) 2026-04-01 17:18:51 -03:00
campaign.rb DEV: Upgrade Patreon plugin to API v2 with v1 backward compatibility (#38871) 2026-03-30 14:43:34 -03:00
patron.rb DEV: Clean up scope resolution operators in plugins (#34979) 2025-09-30 14:36:34 +02:00
pledge.rb DEV: Upgrade Patreon plugin to API v2 with v1 backward compatibility (#38871) 2026-03-30 14:43:34 -03:00
seed.rb DEV: Clean up scope resolution operators in plugins (#34979) 2025-09-30 14:36:34 +02:00
tokens.rb DEV: Upgrade Patreon plugin to API v2 with v1 backward compatibility (#38871) 2026-03-30 14:43:34 -03:00