a }|g@sdZddlZddlmZddlZddlmZddlmZddl m Z ddl m Z ddl m ZeeZeje dd d d Zejee dd d d ZedddZeddddZejddddZdeeddddZdS)z'Subscribes users to the EFF newsletter.N)Optional) configuration) constants)Account)AccountFileStorage)util)configaccreturncCs||jdurdS|jdur@|jdur,tdq^|jj|jd|_n|jr^tr^|jj|jd|_|jjrxt|}||dS)aHigh level function to store potential EFF newsletter subscriptions. The user may be asked if they want to sign up for the newsletter if they have not given their explicit approval or refusal using --eff-mail or --no-eff-mail flag. Decision about EFF subscription will be stored in the account metadata. :param configuration.NamespaceConfig config: Client configuration. :param Account acc: Current client account. FNTz$you didn't provide an e-mail addressregister_to_eff) Z eff_emailemail_report_failuremetaupdate_want_subscriptionr r update_metarr Zstorager9/usr/lib/python3.9/site-packages/certbot/_internal/eff.pyprepare_subscriptions     rcCsH|js |sdS|jjrDt|jj|jjdd|_t|}||dS)aHigh level function to take care of EFF newsletter subscriptions. Once subscription is handled, it will not be handled again. :param configuration.NamespaceConfig config: Client configuration. :param Account acc: Current client account. Nr )dry_runrr subscriberrrrrrrhandle_subscription,s  r)r cCsd}tj|ddS)zDoes the user want to be subscribed to the EFF newsletter? :returns: True if we should subscribe the user, otherwise, False :rtype: bool aoWould you be willing, once your first certificate is successfully issued, to share your email address with the Electronic Frontier Foundation, a founding partner of the Let's Encrypt project and the non-profit organization that develops Certbot? We'd like to send you email about our work encrypting the web, EFF news, campaigns, and ways to support digital freedom. F)default) display_utilZyesno)promptrrrr?sr)r r cCsDtj}d|dd}td|td||ttj||dddS) zhSubscribe the user to the EFF mailing list. :param str email: the e-mail address to subscribe jsonZ%eff_supporters_library_subscribe_form)Z data_typer Zform_idz.Subscribe to the EFF mailing list (email: %s).zSending POST request to %s: %s<)datatimeoutN)rZEFF_SUBSCRIBE_URIloggerinfodebug_check_responserequestsZpost)r urlrrrrrOs r)responser c Csltd|jz ||ds,tdWn8tjjyJtYnt t fyftdYn0dS)zCheck for errors in the server's response. If an error occurred, it will be reported to the user. :param requests.Response response: the server's response to the subscription request zReceived response: %sstatusz)your e-mail address appears to be invalidz,there was a problem with the server responseN) r!r#ZcontentZraise_for_statusrrr% exceptionsZ HTTPError ValueErrorKeyError)r'rrrr$^s    r$)reasonr cCs@dg}|dur"|d|||dtd|dS)zNotify the user of failing to sign them up for the newsletter. :param reason: a phrase describing what the problem was beginning with a lowercase letter and no closing punctuation :type reason: `str` or `None` z4We were unable to subscribe you the EFF mailing listNz because z:. You can try again later by visiting https://act.eff.org.)appendrnotifyjoin)r,msgrrrrrs    r)N)__doc__Zloggingtypingrr%ZcertbotrZcertbot._internalrZcertbot._internal.accountrrZcertbot.displayrrZ getLogger__name__r!ZNamespaceConfigrrboolrstrrZResponser$rrrrrs