Skip to content

Commit

Permalink
fix: avoid raise exception in already unsubscribed user
Browse files Browse the repository at this point in the history
  • Loading branch information
vncsna committed Feb 20, 2024
1 parent dc95b84 commit d094d2f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions bd_api/apps/payment/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,20 @@ def remove_user(email: str, group_key: str = None) -> None:
"""Remove user from google group"""
if not group_key:
group_key = settings.GOOGLE_DIRECTORY_GROUP_KEY
if "+" in email and email.index("+") < email.index("@"):
email = email.split("+")[0] + "@" + email.split("@")[1]
try:
service = get_service()
service.members().delete(
groupKey=group_key,
memberKey=email,
).execute()
except Exception as e:
logger.error(e)
raise e
except HttpError as e:
if e.resp.status == 404:
logger.warning(f"{email} already unsubscribed")
else:
logger.error(e)
raise e


def list_user(group_key: str = None):
Expand Down

0 comments on commit d094d2f

Please sign in to comment.