From be1c23ca8338d867bb28d6a7b886983e43d8ecf5 Mon Sep 17 00:00:00 2001 From: Zach Gollwitzer Date: Fri, 7 Feb 2025 11:03:52 -0500 Subject: [PATCH 1/2] Add data migration for EU Plaid webhooks --- lib/tasks/data_migration.rake | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 lib/tasks/data_migration.rake diff --git a/lib/tasks/data_migration.rake b/lib/tasks/data_migration.rake new file mode 100644 index 00000000000..3d991cd4a6c --- /dev/null +++ b/lib/tasks/data_migration.rake @@ -0,0 +1,23 @@ +namespace :data_migration do + desc "Migrate EU Plaid webhooks" + # 2025-02-07: EU Plaid items need to be moved over to a new webhook URL so that we can + # instantiate the correct Plaid client for verification based on which Plaid instance it comes from + task eu_plaid_webhooks: :environment do + client = Provider::Plaid.new(Rails.application.config.plaid_eu, region: :eu) + + eu_items = PlaidItem.where(plaid_region: "eu") + + eu_items.find_each do |item| + request = Plaid::ItemWebhookUpdateRequest.new( + access_token: item.access_token, + webhook: "https://app.maybefinance.com/webhooks/plaid_eu" + ) + + provider.client.item_webhook_update(request) + + puts "Updated webhook for Plaid item #{item.plaid_id}" + rescue => error + puts "Error updating webhook for Plaid item #{item.plaid_id}: #{error.message}" + end + end +end From ed42c7af6f87a176c98073d290b1efa99d6efe15 Mon Sep 17 00:00:00 2001 From: Zach Gollwitzer Date: Fri, 7 Feb 2025 11:09:01 -0500 Subject: [PATCH 2/2] Fix task --- lib/tasks/data_migration.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/data_migration.rake b/lib/tasks/data_migration.rake index 3d991cd4a6c..c84dbab04d0 100644 --- a/lib/tasks/data_migration.rake +++ b/lib/tasks/data_migration.rake @@ -3,7 +3,7 @@ namespace :data_migration do # 2025-02-07: EU Plaid items need to be moved over to a new webhook URL so that we can # instantiate the correct Plaid client for verification based on which Plaid instance it comes from task eu_plaid_webhooks: :environment do - client = Provider::Plaid.new(Rails.application.config.plaid_eu, region: :eu) + provider = Provider::Plaid.new(Rails.application.config.plaid_eu, region: :eu) eu_items = PlaidItem.where(plaid_region: "eu")