def email_unsubscribe(request, *args, **kwargs): if time.time() > int(kwargs['expiration']): return email_unsubscribe_response( request, 'Your unsubscription link has expired.', error=True) try: email = base64.b64decode(kwargs['email_encoded']) except TypeError: return email_unsubscribe_response(request, 'Invalid unsubscribe link.', error=True) if not EmailBlacklist.verify_email_signature(**kwargs): return email_unsubscribe_response(request, 'Invalid unsubscribe link.', error=True) blacklist_instance = EmailBlacklist(email=email) try: blacklist_instance.save() except IntegrityError: pass return email_unsubscribe_response( request, "You will no longer receive email notifications for earned" " badges from this domain.")
def email_unsubscribe(request, *args, **kwargs): if time.time() > int(kwargs['expiration']): return email_unsubscribe_response( request, 'Your unsubscription link has expired.', error=True) try: email = base64.b64decode(kwargs['email_encoded']).decode("utf-8") except TypeError: logger.event(badgrlog.BlacklistUnsubscribeInvalidLinkEvent(kwargs['email_encoded'])) return email_unsubscribe_response(request, 'Invalid unsubscribe link.', error=True) if not EmailBlacklist.verify_email_signature(**kwargs): logger.event(badgrlog.BlacklistUnsubscribeInvalidLinkEvent(email)) return email_unsubscribe_response(request, 'Invalid unsubscribe link.', error=True) blacklist_instance = EmailBlacklist(email=email) try: blacklist_instance.save() logger.event(badgrlog.BlacklistUnsubscribeRequestSuccessEvent(email)) except IntegrityError: pass except: logger.event(badgrlog.BlacklistUnsubscribeRequestFailedEvent(email)) return email_unsubscribe_response( request, "Failed to unsubscribe email.", error=True) return email_unsubscribe_response( request, "You will no longer receive email notifications for earned" " badges from this domain.")
def email_unsubscribe(request, *args, **kwargs): if time.time() > int(kwargs['expiration']): return HttpResponse('Your unsubscription link has expired.') try: email = base64.b64decode(kwargs['email_encoded']) except TypeError: return HttpResponse('Invalid unsubscribe link.') if not EmailBlacklist.verify_email_signature(**kwargs): return HttpResponse('Invalid unsubscribe link.') blacklist_instance = EmailBlacklist(email=email) try: blacklist_instance.save() except IntegrityError: pass return HttpResponse("You will no longer receive email notifications for \ earned badges from this domain.")