From db537b5c8660ac79f2f1178af8b373bda4d264e7 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Mon, 3 Mar 2025 17:50:08 +0530 Subject: [PATCH] feat: update confirmation url --- .../facebook/confirm_controller.rb | 20 +++++++++++++++++++ app/controllers/facebook/delete_controller.rb | 6 +++--- config/routes.rb | 4 ++-- 3 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 app/controllers/facebook/confirm_controller.rb diff --git a/app/controllers/facebook/confirm_controller.rb b/app/controllers/facebook/confirm_controller.rb new file mode 100644 index 000000000..084c81872 --- /dev/null +++ b/app/controllers/facebook/confirm_controller.rb @@ -0,0 +1,20 @@ +class Facebook::ConfirmController < ApplicationController + class InvalidDigestError < StandardError; end + + def show + @id_to_process = params[:id] + + if processing? + render json: { status: 'Processing' }, status: :ok + else + render json: { status: 'Data Deleted Successfully' }, status: :ok + end + end + + private + + def processing? + key = format(::Redis::Alfred::META_DELETE_PROCESSING, id: @id_to_process) + ::Redis::Alfred.get(key).present? + end +end diff --git a/app/controllers/facebook/delete_controller.rb b/app/controllers/facebook/delete_controller.rb index 5edda877d..17592ca4b 100644 --- a/app/controllers/facebook/delete_controller.rb +++ b/app/controllers/facebook/delete_controller.rb @@ -6,9 +6,9 @@ class Facebook::DeleteController < ApplicationController payload = parse_fb_signed_request(signed_request) id_to_process = payload['user_id'] - set_processing + mark_processing(id_to_process) Webhooks::MetaDeleteJob.perform_later(id_to_process) - status_url = "#{app_url_base}/facebook/confirm?code=#{id_to_process}" + status_url = "#{app_url_base}/facebook/confirm/#{id_to_process}" render json: { status_url: status_url, code: id_to_process }, status: :ok rescue InvalidDigestError @@ -17,7 +17,7 @@ class Facebook::DeleteController < ApplicationController private - def set_processing + def mark_processing(id_to_process) # we use this key to check if the deletion is completed or not # Once the key is gone, we know the deletion is completed # And we can show as such diff --git a/config/routes.rb b/config/routes.rb index 422ea8fff..714086e68 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -455,8 +455,8 @@ Rails.application.routes.draw do end namespace :facebook do - resource :delete, only: [:create] - resource :confirm, only: [:show] + resources :delete, only: [:create] + resources :confirm, only: [:show] end namespace :linear do