1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-04 21:15:19 +02:00

Lazy load Plaid link tokens, fix link issues on broadcast (#2302)

* Lazy load Plaid link tokens, fix link issues on broadcast

* Fix alert styles
This commit is contained in:
Zach Gollwitzer 2025-05-25 08:12:54 -04:00 committed by GitHub
parent c701755b02
commit d21e385962
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 155 additions and 123 deletions

View file

@ -23,24 +23,22 @@ class PlaidItem < ApplicationRecord
scope :needs_update, -> { where(status: :requires_update) }
def get_update_link_token(webhooks_url:, redirect_url:)
begin
family.get_link_token(
webhooks_url: webhooks_url,
redirect_url: redirect_url,
region: plaid_region,
access_token: access_token
)
rescue Plaid::ApiError => e
error_body = JSON.parse(e.response_body)
family.get_link_token(
webhooks_url: webhooks_url,
redirect_url: redirect_url,
region: plaid_region,
access_token: access_token
)
rescue Plaid::ApiError => e
error_body = JSON.parse(e.response_body)
if error_body["error_code"] == "ITEM_NOT_FOUND"
# Mark the connection as invalid but don't auto-delete
update!(status: :requires_update)
raise PlaidConnectionLostError
else
raise e
end
if error_body["error_code"] == "ITEM_NOT_FOUND"
# Mark the connection as invalid but don't auto-delete
update!(status: :requires_update)
end
Sentry.capture_exception(e)
nil
end
def destroy_later
@ -118,6 +116,4 @@ class PlaidItem < ApplicationRecord
def supported_products
available_products + billed_products
end
class PlaidConnectionLostError < StandardError; end
end