@shared_task(bind=True, base=DebugBasketTask, default_retry_delay=BASKET_TASK_RETRY_DELAY, max_retries=BASKET_TASK_MAX_RETRIES)
def unsubscribe_user_task(self, result, newsletters=[], optout=False):
 if (not result):
  return None
 newsletters_to_unsubscribe = []
 if (result.get('status') == 'ok'):
  email = result.get('email')
  token = result.get('token')
  if newsletters:
   newsletters_to_unsubscribe = list(set(newsletters).intersection(result['newsletters']))
  else:
   newsletters_to_unsubscribe = list(set(MOZILLIANS_NEWSLETTERS).intersection(result['newsletters']))
 if newsletters_to_unsubscribe:
  try:
   unsubscribe_result = basket.unsubscribe(token=token, email=email, newsletters=newsletters_to_unsubscribe, optout=optout)
  except MaxRetriesExceededError as exc:
   raise exc
  except basket.BasketException as exc:
   raise self.retry(exc=exc)
  return unsubscribe_result
 return None

@ shared_task ( bind = True , base = DebugBasketTask , default_retry_delay = BASKET_TASK_RETRY_DELAY , max_retries = BASKET_TASK_MAX_RETRIES ) def unsubscribe_user_task ( self , result , newsletters = [ ] , optout = False ) : if ( not result ) : return None newsletters_to_unsubscribe = [ ] if ( result . get ( 'status' ) == 'ok' ) : email = result . get ( 'email' ) token = result . get ( 'token' ) if newsletters : newsletters_to_unsubscribe = list ( set ( newsletters ) . intersection ( result [ 'newsletters' ] ) ) else : newsletters_to_unsubscribe = list ( set ( MOZILLIANS_NEWSLETTERS ) . intersection ( result [ 'newsletters' ] ) ) if newsletters_to_unsubscribe : try : unsubscribe_result = basket . unsubscribe ( token = token , email = email , newsletters = newsletters_to_unsubscribe , optout = optout ) except MaxRetriesExceededError as exc : raise exc except basket . BasketException as exc : raise self . retry ( exc = exc ) return unsubscribe_result return None
removes a user from the basket subscription .