diff --git a/services/supabase/gitauto_manager.py b/services/supabase/gitauto_manager.py index 66b6ec6f..b0662c57 100644 --- a/services/supabase/gitauto_manager.py +++ b/services/supabase/gitauto_manager.py @@ -136,9 +136,12 @@ def create_user_request( return data[1][0]["id"] @handle_exceptions(default_return_value=None, raise_on_error=False) - def delete_installation(self, installation_id: int) -> None: + def delete_installation(self, installation_id: int, user_id: int) -> None: """We don't cancel a subscription associated with this installation id since paid users sometimes mistakenly uninstall our app""" - data = {"uninstalled_at": datetime.now(tz=timezone.utc).isoformat()} + data = { + "uninstalled_at": datetime.now(tz=timezone.utc).isoformat(), + "uninstalled_by": user_id, + } ( self.client.table(table_name="installations") .update(json=data) diff --git a/services/webhook_handler.py b/services/webhook_handler.py index 4b002af0..79520c36 100644 --- a/services/webhook_handler.py +++ b/services/webhook_handler.py @@ -63,7 +63,10 @@ async def handle_installation_created(payload: GitHubInstallationPayload) -> Non async def handle_installation_deleted(payload: GitHubInstallationPayload) -> None: """Soft deletes installation record on GitAuto APP installation""" installation_id: int = payload["installation"]["id"] - supabase_manager.delete_installation(installation_id=installation_id) + user_id: int = payload["sender"]["id"] + supabase_manager.delete_installation( + installation_id=installation_id, user_id=user_id + ) @handle_exceptions(default_return_value=None, raise_on_error=False)