Skip to content

Commit

Permalink
Record user_id when uninstalling
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroshinishio committed Nov 20, 2024
1 parent 9a55b07 commit 36eeba1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 5 additions & 2 deletions services/supabase/gitauto_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion services/webhook_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 36eeba1

Please sign in to comment.