feat: update controllers to create delete request

This commit is contained in:
Shivam Mishra
2025-03-06 20:05:59 +05:30
parent 82408a8e03
commit 1c2c8f26fc
4 changed files with 39 additions and 25 deletions
@@ -6,15 +6,14 @@ class Facebook::DeleteController < ApplicationController
payload = parse_fb_signed_request(signed_request)
id_to_process = payload['user_id']
mark_deleting(id_to_process)
::Channels::Facebook::RedactContactDataJob.perform_later(id_to_process)
status_url = "#{app_url_base}/facebook/confirm/#{id_to_process}"
delete_request = DeleteRequest.create(fb_id: id_to_process)
status_url = "#{app_url_base}/facebook/confirm/#{delete_request.confirmation_code}"
# IMPORTANT: Do not change the response format below.
# Facebook's Data Deletion Request system specifically expects responses in this format
# with a 'url' for status confirmation and a 'confirmation_code' field.
# See: https://developers.facebook.com/docs/development/create-an-app/app-dashboard/data-deletion-callback/#implementing
render json: { url: status_url, confirmation_code: id_to_process }, status: :ok
render json: { url: status_url, confirmation_code: delete_request.confirmation_code }, status: :ok
rescue InvalidDigestError
render json: { error: 'Invalid signature' }, status: :unprocessable_entity
rescue StandardError => e